From 71e51730b782d41f5d98277ade5ab2dcc83c5a85 Mon Sep 17 00:00:00 2001 From: Drew Galbraith Date: Fri, 16 Jun 2023 01:29:00 -0700 Subject: [PATCH] Mark unblocked threads as runnable before enqueueing them --- zion/object/channel.cpp | 4 +++- zion/object/port.cpp | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/zion/object/channel.cpp b/zion/object/channel.cpp index e7513d5..b519dfa 100644 --- a/zion/object/channel.cpp +++ b/zion/object/channel.cpp @@ -82,7 +82,9 @@ z_err_t Channel::EnqueueMessage(const ZMessage& msg) { pending_messages_.PushBack(message); if (blocked_threads_.size() > 0) { - gScheduler->Enqueue(blocked_threads_.PopFront()); + auto thread = blocked_threads_.PopFront(); + thread->SetState(Thread::RUNNABLE); + gScheduler->Enqueue(thread); } return Z_OK; } diff --git a/zion/object/port.cpp b/zion/object/port.cpp index 52e0cf1..dfbd134 100644 --- a/zion/object/port.cpp +++ b/zion/object/port.cpp @@ -27,7 +27,9 @@ z_err_t Port::Write(const ZMessage& msg) { MutexHolder lock(mutex_); pending_messages_.PushBack(message); if (blocked_threads_.size() > 0) { - gScheduler->Enqueue(blocked_threads_.PopFront()); + auto thread = blocked_threads_.PopFront(); + thread->SetState(Thread::RUNNABLE); + gScheduler->Enqueue(thread); } return Z_OK; }