UNISTDX_IPC_SEMAPHORE
enum semaphore_type: int

The scope of semaphore (process/thread).

  • thread = 0
  • process = 1
class sys::posix_semaphore

Semaphore, implemented using POSIX system calls. Suitable for both processes and threads.

Derived classes
Types
  • using clock_type = std::chrono::system_clock

    Clock type used in this class.

Methods
  • notify(int n) -> void

    Notify n processes that wait on this semaphore.

    bad_call

    See
    semop(2)
  • notify_one() -> void

    Notify one process that wait on this semaphore.

    bad_call

    See
    semop(2)
  • 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.

    bad_call

    • If pred is true upon the call to this method no waiting or unlocking is done
    • The mutex is locked when checking for the predicate.

    Return
    predicate value
    See
    semtimedop(2)
  • 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.

    bad_call

    See
    semtimedop(2)
    See
    sem_timedwait(2)
  • 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.

    bad_call

    • If pred is true upon the call to this method no waiting or unlocking is done
    • The mutex is locked when checking for the predicate.

    Return
    predicate value
    See
    sem_timedwait(2)
  • 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.

    bad_call

    See
    sem_timedwait(2)
  • 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.

    bad_call

    • If pred is true upon the call to this method no waiting or unlocking is done
    • The mutex is locked when checking for the predicate.

    Return
    predicate value
    See
    semtimedop(2)
    See
    sem_timedwait(2)
  • 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.

    bad_call

    See
    semtimedop(2)
    See
    sem_timedwait(2)
  • 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.

    bad_call

    • If pred is true upon the call to this method no waiting or unlocking is done
    • The mutex is locked when checking for the predicate.

    See
    semop(2)
    See
    sem_wait(2)
  • template <class Lock>
    wait(Lock & lock) -> void

    Wait on the semaphore unlocking lock for the duration of the wait.

    bad_call

    See
    semop(2)
    See
    sem_wait(2)
  • wait() -> void

    Wait until other process/thread calls sysv_semaphore::notify_one or sysv_semaphore::notify on this semaphore.

    bad_call

    See
    semop(2)
    See
    sem_wait(2)
  • ~posix_semaphore()
  • posix_semaphore(semaphore_type type)explicit

    Construct semaphore with specified type.

    bad_call

class sys::sysv_semaphore

Semaphore, implemented using System V system calls. Suitable for both processes and threads.

Types
  • using clock_type = std::chrono::system_clock

    Clock type used in this class.

  • using sem_type = int

    Alias to system semaphore type (int).

Methods
  • 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.

    bad_call

    • If pred is true upon the call to this method no waiting or unlocking is done
    • The mutex is locked when checking for the predicate.

    Return
    predicate value
    See
    semtimedop(2)
  • 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.

    bad_call

    See
    semtimedop(2)
  • 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.

    bad_call

    • If pred is true upon the call to this method no waiting or unlocking is done
    • The mutex is locked when checking for the predicate.

    Return
    predicate value
    See
    semtimedop(2)
  • 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.

    bad_call

    See
    semtimedop(2)
  • 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.

    bad_call

    • If pred is true upon the call to this method no waiting or unlocking is done
    • The mutex is locked when checking for the predicate.

    Return
    predicate value
    See
    semtimedop(2)
  • 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.

    bad_call

    See
    semtimedop(2)
  • 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.

    bad_call

    • If pred is true upon the call to this method no waiting or unlocking is done
    • The mutex is locked when checking for the predicate.

    See
    semop(2)
  • template <class Lock>
    wait(Lock & lock) -> void

    Wait on the semaphore unlocking lock for the duration of the wait.

    bad_call

    See
    semop(2)
  • notify(int n) -> void

    Notify n processes that wait on this semaphore.

    bad_call

    See
    semop(2)
  • notify_one() -> void

    Notify one process that wait on this semaphore.

    bad_call

    See
    semop(2)
  • wait() -> void

    Wait until other process/thread calls sysv_semaphore::notify_one or sysv_semaphore::notify on this semaphore.

    bad_call

    See
    semop(2)
  • owner() const -> bool

    Check if this semaphore is owned by this process.

  • id() const -> sem_type

    Get semaphore ID.

  • ~sysv_semaphore()

    Remove semaphore (if owner). Terminates on system error.

    See
    semctl(2)
  • 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.

    bad_call

    The semaphore is owned by the calling process/thread.

    See
    semget(2)