pub unsafe fn wait_u32_eq(
addr: *const u32,
expected: u32,
timeout: Option<Duration>,
) -> Result<(), WaitError>Expand description
Wait while the 32-bit value at addr equals expected.
Semantics (mirrors futex / WaitOnAddress):
- If
*addr != expected, returns immediately withOk(()). - Otherwise, blocks until woken, the value changes, or
timeoutelapses.
This call may return Ok(()) even if the value is still equal (spurious wakeups); callers
should always re-check the condition in a loop.
§Errors
WaitError::TimedOut:timeoutelapsed.WaitError::Interrupted: interrupted by a signal (Linux).WaitError::OsError: platform-specific failure (errno on Linux;GetLastErroron Windows).WaitError::Unsupported: this target has no implementation (non-Linux / non-Windows).
§Safety
addrmust be valid to read au32for the duration of the call.addrmust be aligned to 4 bytes.- If other threads/processes mutate the value concurrently, the memory at
addrmust be accessed in a race-free way (typically by storing through anAtomicU32at the same address and passing its pointer cast to*const u32).