Semaphore, implemented using POSIX system calls. Suitable for both processes and threads.
notify(int n) -> void
Notify n processes that wait on this semaphore.
notify_one() -> voidNotify one process that wait on this semaphore.
template <class Lock, class Clock, class Duration, class Pred> wait_until(Lock & lock, const std::chrono::time_point< Clock, Duration > & tp, Pred pred) -> bool
Wait on the semaphore until specified time dur unlocking lock for the duration of the wait until predicate pred becomes true or timeout occurs.
pred is true upon the call to this method no waiting or unlocking is done
template <class Lock, class Clock, class Duration> wait_until(Lock & lock, const std::chrono::time_point< Clock, Duration > & tp) -> std::cv_status
Wait on the semaphore until specified time tp unlocking lock for the duration of the wait.
template <class Lock, class Duration, class Pred> wait_until(Lock & lock, const std::chrono::time_point< clock_type, Duration > & tp, Pred pred) -> bool
Wait on the semaphore until specified time tp unlocking lock for the duration of the wait until predicate pred becomes true.
pred is true upon the call to this method no waiting or unlocking is done
template <class Lock, class Duration> wait_until(Lock & lock, const std::chrono::time_point< clock_type, Duration > & tp) -> std::cv_status
Wait on the semaphore until specified time tp unlocking lock for the duration of the wait.
template <class Lock, class Rep, class Period, class Pred> wait_for(Lock & lock, const std::chrono::duration< Rep, Period > & dur, Pred pred) -> bool
Wait on the semaphore specified amount of time dur unlocking lock for the duration of the wait until predicate pred becomes true or timeout occurs.
pred is true upon the call to this method no waiting or unlocking is done
template <class Lock, class Rep, class Period> wait_for(Lock & lock, const std::chrono::duration< Rep, Period > & dur) -> std::cv_status
Wait on the semaphore specified amount of time dur unlocking lock for the duration of the wait.
template <class Lock, class Pred> wait(Lock & lock, Pred pred) -> void
Wait on the semaphore unlocking lock for the duration of the wait until predicate pred becomes true.
pred is true upon the call to this method no waiting or unlocking is done
template <class Lock> wait(Lock & lock) -> void
Wait on the semaphore unlocking lock for the duration of the wait.
wait() -> voidWait until other process/thread calls sysv_semaphore::notify_one or sysv_semaphore::notify on this semaphore.
~posix_semaphore()posix_semaphore(semaphore_type type)explicit
Construct semaphore with specified type.
Semaphore, implemented using System V system calls. Suitable for both processes and threads.
using clock_type = std::chrono::system_clockClock type used in this class.
using sem_type = intAlias to system semaphore type (int).
template <class Lock, class Clock, class Duration, class Pred> wait_until(Lock & lock, const std::chrono::time_point< Clock, Duration > & tp, Pred pred) -> bool
Wait on the semaphore until specified time dur unlocking lock for the duration of the wait until predicate pred becomes true or timeout occurs.
pred is true upon the call to this method no waiting or unlocking is done
template <class Lock, class Clock, class Duration> wait_until(Lock & lock, const std::chrono::time_point< Clock, Duration > & tp) -> std::cv_status
Wait on the semaphore until specified time tp unlocking lock for the duration of the wait.
template <class Lock, class Duration, class Pred> wait_until(Lock & lock, const std::chrono::time_point< clock_type, Duration > & tp, Pred pred) -> bool
Wait on the semaphore until specified time tp unlocking lock for the duration of the wait until predicate pred becomes true.
pred is true upon the call to this method no waiting or unlocking is done
template <class Lock, class Duration> wait_until(Lock & lock, const std::chrono::time_point< clock_type, Duration > & tp) -> std::cv_status
Wait on the semaphore until specified time tp unlocking lock for the duration of the wait.
template <class Lock, class Rep, class Period, class Pred> wait_for(Lock & lock, const std::chrono::duration< Rep, Period > & dur, Pred pred) -> bool
Wait on the semaphore specified amount of time dur unlocking lock for the duration of the wait until predicate pred becomes true or timeout occurs.
pred is true upon the call to this method no waiting or unlocking is done
template <class Lock, class Rep, class Period> wait_for(Lock & lock, const std::chrono::duration< Rep, Period > & dur) -> std::cv_status
Wait on the semaphore specified amount of time dur unlocking lock for the duration of the wait.
template <class Lock, class Pred> wait(Lock & lock, Pred pred) -> void
Wait on the semaphore unlocking lock for the duration of the wait until predicate pred becomes true.
pred is true upon the call to this method no waiting or unlocking is done
template <class Lock> wait(Lock & lock) -> void
Wait on the semaphore unlocking lock for the duration of the wait.
notify(int n) -> void
Notify n processes that wait on this semaphore.
notify_one() -> voidNotify one process that wait on this semaphore.
wait() -> voidWait until other process/thread calls sysv_semaphore::notify_one or sysv_semaphore::notify on this semaphore.
owner() const -> boolCheck if this semaphore is owned by this process.
id() const -> sem_typeGet semaphore ID.
~sysv_semaphore()Remove semaphore (if owner). Terminates on system error.
sysv_semaphore(sem_type sem)explicit
Construct semaphore with ID sem.
The semaphore is not owned by the calling process/thread.
sysv_semaphore(mode_type mode = 0600)explicit
Construct semaphore with specified mode.
The semaphore is owned by the calling process/thread.