aboutsummaryrefslogtreecommitdiff
path: root/zencore/include
diff options
context:
space:
mode:
authorMartin Ridgers <[email protected]>2021-11-11 12:53:05 +0100
committerMartin Ridgers <[email protected]>2021-11-11 13:14:23 +0100
commitd312856e0cb89be73f16e328858eb5ab04aeec02 (patch)
tree5275db2837c224f0f06762c64bcb77d43395def6 /zencore/include
parentCheck if an event is already set before waiting on it (diff)
downloadzen-d312856e0cb89be73f16e328858eb5ab04aeec02.tar.xz
zen-d312856e0cb89be73f16e328858eb5ab04aeec02.zip
NamedEvent is no longer an Event-type object.
Platforms other than Windows do not really have a named event-like primitive or ones that are close are fallible if a process hard-terminates. Separating from Event more clearly conveys the use of NamedEvent objects; to synchronise two processes.
Diffstat (limited to 'zencore/include')
-rw-r--r--zencore/include/zencore/thread.h31
1 files changed, 28 insertions, 3 deletions
diff --git a/zencore/include/zencore/thread.h b/zencore/include/zencore/thread.h
index 3feb12936..2fe7cc63e 100644
--- a/zencore/include/zencore/thread.h
+++ b/zencore/include/zencore/thread.h
@@ -102,11 +102,36 @@ protected:
/** Basic abstraction of an IPC mechanism (aka 'binary semaphore')
*/
-class NamedEvent : public Event
+class NamedEvent
{
public:
- ZENCORE_API explicit NamedEvent(std::string_view EventName);
- ZENCORE_API explicit NamedEvent(std::u8string_view EventName);
+ NamedEvent() = default;
+ ZENCORE_API explicit NamedEvent(std::string_view EventName);
+ ZENCORE_API explicit NamedEvent(std::u8string_view EventName);
+ ZENCORE_API ~NamedEvent();
+ ZENCORE_API void Close();
+ ZENCORE_API void Set();
+ ZENCORE_API bool Wait(int TimeoutMs=-1);
+
+ NamedEvent(NamedEvent&& Rhs) noexcept
+ : m_EventHandle(Rhs.m_EventHandle)
+ {
+ Rhs.m_EventHandle = nullptr;
+ }
+
+ inline NamedEvent& operator = (NamedEvent&& Rhs) noexcept
+ {
+ std::swap(m_EventHandle, Rhs.m_EventHandle);
+ return *this;
+ }
+
+
+protected:
+ void* m_EventHandle = nullptr;
+
+private:
+ NamedEvent(const NamedEvent& Rhs) = delete;
+ NamedEvent& operator = (const NamedEvent& Rhs) = delete;
};
/** Basic abstraction of a named (system wide) mutex primitive