12#ifndef ROC_CORE_SEMAPHORE_H_
13#define ROC_CORE_SEMAPHORE_H_
25class Semaphore :
public NonCopyable<> {
Atomic integer. Provides sequential consistency. For a fine-grained memory order control,...
Semaphore(unsigned counter=0)
Initialize semaphore with given counter.
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.