Checks if ptr
still contains the value expect
and, if so, blocks the caller until either:
- The value at
ptr
is no longer equal toexpect
. - The caller is unblocked by a matching
wake()
. - The caller is unblocked spuriously (“at random”).
The checking of ptr
and expect
, along with blocking the caller, is done atomically and totally ordered (sequentially consistent) with respect to other wait()/wake() calls on the same ptr
.