ADTF
Loading...
Searching...
No Matches
semaphore_decl.h
Go to the documentation of this file.
1
14
15#ifndef A_UTIL_UTIL_CONCURRENCY_DETAIL_SEMAPHORE_DECL_HEADER_INCLUDED
16#define A_UTIL_UTIL_CONCURRENCY_DETAIL_SEMAPHORE_DECL_HEADER_INCLUDED
17
18#include <chrono>
19
20namespace a_util {
21namespace concurrency {
22namespace detail {
30template <typename Mutex, typename CondVar>
31class basic_semaphore {
32 basic_semaphore(const basic_semaphore&); // = delete;
33 basic_semaphore& operator=(const basic_semaphore&); // = delete;
34
35public:
40 explicit basic_semaphore(int count = 0);
41
43 void notify();
44
46 void wait();
47
52 bool try_wait();
53
62 template <typename Rep, typename Period>
63 bool wait_for(const std::chrono::duration<Rep, Period>& timeout);
64
66 void reset();
67
72 bool is_set();
73
74protected:
75 Mutex _mutex;
76 CondVar _cv;
78};
79
80} // namespace detail
81} // namespace concurrency
82} // namespace a_util
83
87
88#endif // A_UTIL_UTIL_CONCURRENCY_DETAIL_SEMAPHORE_DECL_HEADER_INCLUDED
void wait()
Decrement the counter, blocks until the count becomes non-zero (if neccessary)
Definition semaphore_impl.h:48
void notify()
Increment the counter and notify any waiters.
Definition semaphore_impl.h:40
bool is_set()
Definition semaphore_impl.h:79
basic_semaphore(int count=0)
Definition semaphore_impl.h:34
void reset()
Reset the counter to 0.
Definition semaphore_impl.h:72
bool try_wait()
Definition semaphore_impl.h:58
bool wait_for(const std::chrono::duration< Rep, Period > &timeout)
Definition semaphore_impl.h:87
Serves as namespace for concurrency implementation details.
Definition concurrency.h:33
Definition concurrency.h:24
Serves as the root component, with common functionality documented in core functionality.
Definition base.h:24