Mark unblocked threads as runnable before enqueueing them

This commit is contained in:
Drew Galbraith 2023-06-16 01:29:00 -07:00
parent ffa2d97a64
commit 71e51730b7
2 changed files with 6 additions and 2 deletions

View File

@ -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;
}

View File

@ -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;
}