You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
as it stands tryWaitAndPop will exit false on timeout or item inserted if the queue was empty when entered
if the return was wrapped in an if queue.empty() cause and in fact the while is superfluious
the code could be just if (queue.empty()) { signal.wait_for(lock, std::chrono::milliseconds(_milli)); if (queue.empty()) { return false; } }
this would make the function atomic as the lock would not get released if you entered it when the queue was empty and an item was added, which as it stands could be consumed by another waiter.
The text was updated successfully, but these errors were encountered:
savemii/include/LockingQueue.h
Line 48 in 987ff28
as it stands tryWaitAndPop will exit false on timeout or item inserted if the queue was empty when entered
if the return was wrapped in an if queue.empty() cause and in fact the while is superfluious
the code could be just
if (queue.empty()) { signal.wait_for(lock, std::chrono::milliseconds(_milli)); if (queue.empty()) { return false; } }
this would make the function atomic as the lock would not get released if you entered it when the queue was empty and an item was added, which as it stands could be consumed by another waiter.
The text was updated successfully, but these errors were encountered: