summaryrefslogtreecommitdiffstats
path: root/src/OSSupport/Event.h
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2015-06-22 22:27:13 +0200
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2015-06-22 22:27:13 +0200
commit33fc1474d90ea68df862e5a5c15980a11961bf16 (patch)
tree0db0968d8078cc0fc1fbd164f080f9e0d32f553e /src/OSSupport/Event.h
parentReinstate "Chunk queue collapsing" (diff)
downloadcuberite-33fc1474d90ea68df862e5a5c15980a11961bf16.tar
cuberite-33fc1474d90ea68df862e5a5c15980a11961bf16.tar.gz
cuberite-33fc1474d90ea68df862e5a5c15980a11961bf16.tar.bz2
cuberite-33fc1474d90ea68df862e5a5c15980a11961bf16.tar.lz
cuberite-33fc1474d90ea68df862e5a5c15980a11961bf16.tar.xz
cuberite-33fc1474d90ea68df862e5a5c15980a11961bf16.tar.zst
cuberite-33fc1474d90ea68df862e5a5c15980a11961bf16.zip
Diffstat (limited to 'src/OSSupport/Event.h')
-rw-r--r--src/OSSupport/Event.h11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/OSSupport/Event.h b/src/OSSupport/Event.h
index 572388a3f..2c58ba485 100644
--- a/src/OSSupport/Event.h
+++ b/src/OSSupport/Event.h
@@ -12,6 +12,7 @@
#include <mutex>
#include <condition_variable>
+#include <atomic>
@@ -28,7 +29,11 @@ public:
/** Sets the event - releases one thread that has been waiting in Wait().
If there was no thread waiting, the next call to Wait() will not block. */
- void Set (void);
+ void Set(void);
+
+ /** Sets the event - releases all threads that have been waiting in Wait().
+ If there was no thread waiting, the next call to Wait() will not block. */
+ void SetAll(void);
/** Waits for the event until either it is signalled, or the (relative) timeout is passed.
Returns true if the event was signalled, false if the timeout was hit or there was an error. */
@@ -37,9 +42,9 @@ public:
private:
/** Used for checking for spurious wakeups. */
- bool m_ShouldWait;
+ std::atomic<bool> m_ShouldContinue;
- /** Mutex protecting m_ShouldWait from multithreaded access. */
+ /** Mutex protecting m_ShouldContinue from multithreaded access. */
std::mutex m_Mutex;
/** The condition variable used as the Event. */