12 #ifndef ROC_CORE_SEMAPHORE_H_
13 #define ROC_CORE_SEMAPHORE_H_
26 class Semaphore :
public NonCopyable<> {
#define ROC_ATTR_NODISCARD
Emit warning if function result is not checked.
Semaphore(unsigned counter=0)
Initialize semaphore with given counter.
ROC_ATTR_NODISCARD bool timed_wait(nanoseconds_t deadline)
Wait until the counter becomes non-zero, decrement it, and return true. If deadline expires before th...
void wait()
Wait until the counter becomes non-zero, decrement it, and return.
void post()
Increment counter and wake up blocked waits. This method is lock-free at least on recent glibc and mu...
int64_t nanoseconds_t
Nanoseconds.