We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fa11b1a commit 413b36cCopy full SHA for 413b36c
1 file changed
modules/Thread/Event.mpp
@@ -0,0 +1,37 @@
1
+export module CppUtils.Thread.Event;
2
+
3
+import std;
4
5
+export namespace CppUtils::Thread
6
+{
7
+ class Event final
8
+ {
9
+ public:
10
+ void wait()
11
12
+ auto lock = std::unique_lock{m_mutex};
13
+ m_conditionVariable.wait(lock, [this]() { return m_triggered; });
14
+ m_triggered = false;
15
+ }
16
17
+ void notify()
18
19
20
21
+ m_triggered = true;
22
23
+ m_conditionVariable.notify_all();
24
25
26
+ void reset()
27
28
29
30
31
32
+ private:
33
+ std::mutex m_mutex;
34
+ std::condition_variable m_conditionVariable;
35
+ bool m_triggered = false;
36
+ };
37
+}
0 commit comments