From 9265df342fa75fbcf11e5b3d4a44bd2b1275feb8 Mon Sep 17 00:00:00 2001 From: Alexander Damian Date: Thu, 23 May 2019 09:11:48 -0400 Subject: [PATCH] Changed empty condition signal to be under queue lock Signed-off-by: Alexander Damian --- quantum/impl/quantum_task_queue_impl.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/quantum/impl/quantum_task_queue_impl.h b/quantum/impl/quantum_task_queue_impl.h index f55111a..778bac6 100644 --- a/quantum/impl/quantum_task_queue_impl.h +++ b/quantum/impl/quantum_task_queue_impl.h @@ -356,10 +356,6 @@ TaskQueue::TaskListIter TaskQueue::advance() acquireWaiting(); } _isAdvanced = false; //reset flag - if (_queueIt == _runQueue.end()) - { - signalEmptyCondition(true); - } return _queueIt; } @@ -373,12 +369,17 @@ inline void TaskQueue::acquireWaiting() { //========================= LOCKED SCOPE ========================= + SpinLock::Guard lock(_spinlock); + bool isEmpty = _runQueue.empty(); if (_waitQueue.empty()) { + if (isEmpty) + { + signalEmptyCondition(true); + } _queueIt = _runQueue.begin(); return; } - bool isEmpty = _runQueue.empty(); if (!isEmpty) { //rewind by one since we are at end() @@ -386,7 +387,6 @@ void TaskQueue::acquireWaiting() } { //splice wait queue unto run queue. - SpinLock::Guard lock(_spinlock); _runQueue.splice(_runQueue.end(), _waitQueue); } if (!isEmpty)