diff options
author | worktycho <work.tycho@gmail.com> | 2015-07-04 15:43:00 +0200 |
---|---|---|
committer | worktycho <work.tycho@gmail.com> | 2015-07-04 15:43:00 +0200 |
commit | 106e06617afea6e07e99c7674b2d10ece96b1344 (patch) | |
tree | bc1237dd50c603f1f5e806574d8496f4f361b29c /src/OSSupport/Event.h | |
parent | Merge pull request #2312 from SamJBarney/master (diff) | |
parent | Fixed minor errors in Tycho's code (diff) | |
download | cuberite-106e06617afea6e07e99c7674b2d10ece96b1344.tar cuberite-106e06617afea6e07e99c7674b2d10ece96b1344.tar.gz cuberite-106e06617afea6e07e99c7674b2d10ece96b1344.tar.bz2 cuberite-106e06617afea6e07e99c7674b2d10ece96b1344.tar.lz cuberite-106e06617afea6e07e99c7674b2d10ece96b1344.tar.xz cuberite-106e06617afea6e07e99c7674b2d10ece96b1344.tar.zst cuberite-106e06617afea6e07e99c7674b2d10ece96b1344.zip |
Diffstat (limited to 'src/OSSupport/Event.h')
-rw-r--r-- | src/OSSupport/Event.h | 11 |
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. */ |