17 #ifndef COM_BORA_SOFTWARE__BALAU_CONCURRENT__SEMAPHORE 18 #define COM_BORA_SOFTWARE__BALAU_CONCURRENT__SEMAPHORE 20 #include <condition_variable> 31 public:
explicit Semaphore(
unsigned int count_ = 0) : count(count_) {}
37 std::lock_guard<std::mutex> lock(mutex);
39 conditionVariable.notify_one();
46 std::unique_lock<std::mutex> lock(mutex);
49 conditionVariable.wait(lock);
57 private: std::mutex mutex;
58 private: std::condition_variable conditionVariable;
59 private:
unsigned int count;
64 #endif // COM_BORA_SOFTWARE__BALAU_CONCURRENT__SEMAPHORE void increment()
Increment the semaphore.
Definition: Semaphore.hpp:36
Traditional semaphore synchronisation object.
Definition: Semaphore.hpp:27
Concurrency control classes.
Definition: CyclicBarrier.hpp:26
Semaphore(unsigned int count_=0)
Create a semaphore object, setting an initial count if desired.
Definition: Semaphore.hpp:31
void decrement()
Decrement the semaphore, blocking if the count is zero.
Definition: Semaphore.hpp:45