Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix data race checking the queue length in dequeue (#454)
If we are working with q.queue we must hold the lock to make sure there is no race conditions. During Dequeue we weren't holding the lock when we checked the length of queue. After this commit we hold the lock to check the length of q.queue. If the queue is empty we unlock the mutex to allow an item to be added to the queue while we wait for a itemAdded notification. The lock is then regained to dequeue the item that was added. If the queue isn't empty we continue to hold the lock and move straight to dequeue the item defering the unlock until the function completes.
- Loading branch information