P99

◆ p99_futex_exchange()

unsigned p99_futex_exchange ( p99_futex volatile *  p00_fut,
unsigned  p00_desired,
unsigned  p00_cstart,
unsigned  p00_clen,
unsigned  p00_wmin,
unsigned  p00_wmax 
)
related

Unconditionally and atomically set the futex p00_fut to value p00_desired.

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.

Also signals eventual waiters if the futex falls within the given range.

Returns
the previous value of the futex
Remarks
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.
This signaling of waiters might not be performed if the counter reached p00_cstart because it wrapped around.
p00_clen defaults to 1u
p00_wmin defaults to 0u
p00_wmax defaults to P99_FUTEX_MAX_WAITERS
p99_futex_exchange 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_cm::p99_cm_trylock().