aboutsummaryrefslogtreecommitdiff
path: root/zencore/thread.cpp
diff options
context:
space:
mode:
authorMartin Ridgers <[email protected]>2021-11-25 14:35:40 +0100
committerMartin Ridgers <[email protected]>2021-11-25 14:37:40 +0100
commit653ed99f4e6e72a87a3f7c8d66418f04a7ab5a39 (patch)
tree4b4925ca0be00ec17802d40145c68371987d7bc0 /zencore/thread.cpp
parentDeleted an unnecessary call to check if a messsge is populated (diff)
downloadzen-653ed99f4e6e72a87a3f7c8d66418f04a7ab5a39.tar.xz
zen-653ed99f4e6e72a87a3f7c8d66418f04a7ab5a39.zip
It reads better to check if something empty than the opposite
Diffstat (limited to 'zencore/thread.cpp')
-rw-r--r--zencore/thread.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/zencore/thread.cpp b/zencore/thread.cpp
index 78238a3d5..981d2bd96 100644
--- a/zencore/thread.cpp
+++ b/zencore/thread.cpp
@@ -236,12 +236,12 @@ Event::Wait(int TimeoutMs)
//////////////////////////////////////////////////////////////////////////
#if ZEN_PLATFORM_LINUX
-static bool IsThereAMessageInQueue(int Fd)
+static bool IsMessageQueueEmpty(int Fd)
{
// Check if there is already a message in the queue.
mq_attr Attributes = { O_NONBLOCK, 1, 1, 0 };
mq_getattr(Fd, &Attributes);
- return (Attributes.mq_curmsgs > 0);
+ return (Attributes.mq_curmsgs == 0);
}
#endif // ZEN_PLATFORM_LINUX
@@ -278,7 +278,7 @@ NamedEvent::NamedEvent(std::string_view EventName)
int LockResult = flock(Inner, LOCK_EX|LOCK_NB);
if (LockResult == 0)
{
- ZEN_ASSERT( IsThereAMessageInQueue(Inner) == false,
+ ZEN_ASSERT( IsMessageQueueEmpty(Inner),
"Ownership of a non-empty '{}' message queue occurred", Name.c_str());
}
@@ -325,7 +325,7 @@ void NamedEvent::Set()
#elif ZEN_PLATFORM_LINUX
int Inner = int(intptr_t(m_EventHandle));
- if (IsThereAMessageInQueue(Inner))
+ if (!IsMessageQueueEmpty(Inner))
{
return;
}
@@ -355,7 +355,7 @@ bool NamedEvent::Wait(int TimeoutMs)
#elif ZEN_PLATFORM_LINUX
int Inner = int(intptr_t(m_EventHandle));
- if (IsThereAMessageInQueue(Inner))
+ if (!IsMessageQueueEmpty(Inner))
{
return true;
}