P99

◆ p99_futex_add()

unsigned p99_futex_add ( p99_futex volatile *  p00_fut,
unsigned  p00_hmuch,
unsigned  p00_cstart,
unsigned  p00_clen,
unsigned  p00_wmin,
unsigned  p00_wmax 
)
related

increment the counter of p00_fut atomically by p00_hmuch.

Returns
the previous value of the counter

After effecting the operation atomically, some waiters on this p99_futex will be woken up if the new value of the futex is in the range that is specified by the arguments p00_cstart and p00_clen. See P99_FUTEX_COMPARE_EXCHANGE for more details on the rules for the p00_wmin and p00_wmax counts.

If p00_hmuch is 0, nothing is added so p99_futex_add is equivalent to p99_futex_load but with the additional effect that waiters might be woken up.

Remarks
to decrement the counter, just pass a negative argument to p00_hmuch. The modulo arithmetic for unsigned will do the rest for you.
Waiters that wait for a value in the p00_clen element range starting at p00_cstart will be woken up if the counter reaches that value with this operation.
p00_clen defaults to 1u
p00_wmin defaults to 0u
p00_wmax defaults to P99_FUTEX_MAX_WAITERS
p99_futex_add is actually implemented as a macro that helps to provide default arguments to the real function.
See also
P99_CALL_DEFARG
P99_DECLARE_DEFARG

Referenced by p99_iterator::p99_iterator_signal().