aboutsummaryrefslogtreecommitdiff
path: root/src/zencore/include
diff options
context:
space:
mode:
authorDan Engelbrecht <[email protected]>2023-11-17 14:38:13 +0100
committerGitHub <[email protected]>2023-11-17 14:38:13 +0100
commitb0082066596178f7b72d9963bffdec306a5b6250 (patch)
tree83505561e50e8a09237b05bddb579a714344c219 /src/zencore/include
parentuse dynamic port assignment for tests (#545) (diff)
downloadzen-b0082066596178f7b72d9963bffdec306a5b6250.tar.xz
zen-b0082066596178f7b72d9963bffdec306a5b6250.zip
fix named event (#553)
* fix named event timout and test, fix blocking queue
Diffstat (limited to 'src/zencore/include')
-rw-r--r--src/zencore/include/zencore/blockingqueue.h24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/zencore/include/zencore/blockingqueue.h b/src/zencore/include/zencore/blockingqueue.h
index 995ba6bfb..e91fdc659 100644
--- a/src/zencore/include/zencore/blockingqueue.h
+++ b/src/zencore/include/zencore/blockingqueue.h
@@ -30,19 +30,22 @@ public:
bool WaitAndDequeue(T& Item)
{
std::unique_lock Lock(m_Lock);
- if (m_Queue.empty() && !m_CompleteAdding)
+ if (m_Queue.empty())
{
+ if (m_CompleteAdding)
+ {
+ return false;
+ }
m_NewItemSignal.wait(Lock, [this]() { return !m_Queue.empty() || m_CompleteAdding; });
+ if (m_Queue.empty())
+ {
+ ZEN_ASSERT(m_CompleteAdding);
+ return false;
+ }
}
-
- if (!m_Queue.empty())
- {
- Item = std::move(m_Queue.front());
- m_Queue.pop_front();
- return true;
- }
-
- return false;
+ Item = std::move(m_Queue.front());
+ m_Queue.pop_front();
+ return true;
}
void CompleteAdding()
@@ -50,7 +53,6 @@ public:
std::unique_lock Lock(m_Lock);
if (!m_CompleteAdding)
{
- ZEN_ASSERT(m_Queue.empty());
m_CompleteAdding = true;
Lock.unlock();