summaryrefslogtreecommitdiff
path: root/libadhocutil/semaphore.h
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2020-05-31 16:40:20 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2020-06-17 22:32:38 +0100
commit6504434262ec98c603f4ba25ed86d6a5a3a1b96a (patch)
tree0032f750351a44544f7b6c96afa760dd34c11511 /libadhocutil/semaphore.h
parentBuild in C++20 (diff)
downloadlibadhocutil-6504434262ec98c603f4ba25ed86d6a5a3a1b96a.tar.bz2
libadhocutil-6504434262ec98c603f4ba25ed86d6a5a3a1b96a.tar.xz
libadhocutil-6504434262ec98c603f4ba25ed86d6a5a3a1b96a.zip
Clang-format
Diffstat (limited to 'libadhocutil/semaphore.h')
-rw-r--r--libadhocutil/semaphore.h35
1 files changed, 17 insertions, 18 deletions
diff --git a/libadhocutil/semaphore.h b/libadhocutil/semaphore.h
index bb20324..b3633b0 100644
--- a/libadhocutil/semaphore.h
+++ b/libadhocutil/semaphore.h
@@ -4,33 +4,32 @@
// Borrowed from StackOverflow
// http://stackoverflow.com/questions/4792449/c0x-has-no-semaphores-how-to-synchronize-threads
+#include "visibility.h"
#include <condition_variable>
#include <mutex>
-#include "visibility.h"
namespace AdHoc {
/// A portable semaphore with timeout support
class DLL_PUBLIC Semaphore {
- public:
- /// Construct a new semaphore with optional initial count.
- explicit Semaphore(unsigned int initial = 0);
+ public:
+ /// Construct a new semaphore with optional initial count.
+ explicit Semaphore(unsigned int initial = 0);
- /// Notify one waiting thread.
- void notify();
- /// Wait for a single count.
- void wait();
- /// Wait for a single count with timeout.
- /// @param ms Timeout in milliseconds.
- bool wait(unsigned int ms);
- /// Free
- [[nodiscard]] unsigned int freeCount() const;
+ /// Notify one waiting thread.
+ void notify();
+ /// Wait for a single count.
+ void wait();
+ /// Wait for a single count with timeout.
+ /// @param ms Timeout in milliseconds.
+ bool wait(unsigned int ms);
+ /// Free
+ [[nodiscard]] unsigned int freeCount() const;
- private:
- std::mutex mutex;
- std::condition_variable condition;
- unsigned long count;
+ private:
+ std::mutex mutex;
+ std::condition_variable condition;
+ unsigned long count;
};
}
#endif
-