aboutsummaryrefslogtreecommitdiff
path: root/zencore/thread.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'zencore/thread.cpp')
-rw-r--r--zencore/thread.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/zencore/thread.cpp b/zencore/thread.cpp
index 981d2bd96..ee62b5248 100644
--- a/zencore/thread.cpp
+++ b/zencore/thread.cpp
@@ -278,8 +278,14 @@ NamedEvent::NamedEvent(std::string_view EventName)
int LockResult = flock(Inner, LOCK_EX|LOCK_NB);
if (LockResult == 0)
{
- ZEN_ASSERT( IsMessageQueueEmpty(Inner),
- "Ownership of a non-empty '{}' message queue occurred", Name.c_str());
+ // This is really thread safe as the message queue could be set between
+ // getting the exclusive lock and checking the queue. But for the our
+ // simple synchronising of process, this should be okay.
+ while (!IsMessageQueueEmpty(Inner))
+ {
+ char Sink;
+ mq_receive(Inner, &Sink, sizeof(Sink), nullptr);
+ }
}
m_EventHandle = (void*)intptr_t(Inner);