CppCommon 1.0.5.0
C++ Common Library
Loading...
Searching...
No Matches
event_manual_reset.h
Go to the documentation of this file.
1
9#ifndef CPPCOMMON_THREADS_EVENT_MANUAL_RESET_H
10#define CPPCOMMON_THREADS_EVENT_MANUAL_RESET_H
11
12#include "time/timestamp.h"
13
14#include <memory>
15
16namespace CppCommon {
17
19
29{
30public:
32
35 explicit EventManualReset(bool signaled = false);
39
42
44
50 void Reset();
51
53
58 void Signal();
59
61
66 bool TryWait();
67
69
75 bool TryWaitFor(const Timespan& timespan);
77
83 bool TryWaitUntil(const UtcTimestamp& timestamp)
84 { return TryWaitFor(timestamp - UtcTimestamp()); }
85
87
90 void Wait();
91
92private:
93 class Impl;
94
95 Impl& impl() noexcept { return reinterpret_cast<Impl&>(_storage); }
96 const Impl& impl() const noexcept { return reinterpret_cast<Impl const&>(_storage); }
97
98 static const size_t StorageSize = 128;
99 static const size_t StorageAlign = 8;
100 alignas(StorageAlign) std::byte _storage[StorageSize];
101};
102
105} // namespace CppCommon
106
107#endif // CPPCOMMON_THREADS_EVENT_MANUAL_RESET_H
Manual-reset event synchronization primitive.
bool TryWait()
Try to wait the event without block.
EventManualReset(EventManualReset &&event)=delete
EventManualReset & operator=(EventManualReset &&event)=delete
bool TryWaitFor(const Timespan &timespan)
Try to wait the event for the given timespan.
EventManualReset & operator=(const EventManualReset &)=delete
EventManualReset(const EventManualReset &)=delete
bool TryWaitUntil(const UtcTimestamp &timestamp)
Try to wait the event until the given timestamp.
void Wait()
Try to wait the event with block.
void Signal()
Signal one of waiting thread about event occurred.
C++ Common project definitions.
Timestamp definition.