P99

◆ p99_cm

typedef struct p99_cm p99_cm

A simple condition-mutex data structure.

This combines elements of standard mtx_t and cnd_t into one simple lock. Namely it implements three basic control interfaces p99_cm_lock, p99_cm_unlock and p99_cm_wait.

There is no separate interface that would correspond to ::cnd_signal or ::cnd_broadcast, because the wake up functionality is already integrated into p99_cm_unlock.

This is meant to be simple or even simplistic:

  • There are no variants of this that would correspond to recursive or timed locks.
  • None of the blocking states can be canceled.
  • Ownership of the lock is not tracked.
    • If a thread calls p99_cm_unlock while another thread effectively holds the lock and relies on the fact that he is alone in a critical section, bad things can happen.
    • If the thread that was holding the lock has exited, p99_cm_unlock can be used to unblock the condition-mutex.
See also
p99_cm_lock
p99_cm_unlock
p99_cm_trylock
p99_cm_wait
P99_CM_EXCLUDE

Definition at line 63 of file p99_cm.h.