Futexes v0.1.0
Waiting on a word and waking its waiters through futex.
FutexWaitPrivate
pub const FutexWaitPrivate: int32 = 128;
FUTEX_WAIT_PRIVATE: sleep while the word holds the expected value.
FutexWakePrivate
pub const FutexWakePrivate: int32 = 129;
FUTEX_WAKE_PRIVATE: wake threads sleeping on the word.
FutexWait
pub func FutexWait(
address: *uint32,
expected: uint32,
timeout: *Timespec
) -> int64
Sleeps while *address equals expected, until a wake, a signal or the timeout.
Returns at once with -EAGAIN when the word already differs, which is how a caller learns it changed.
See also: https://man7.org/linux/man-pages/man2/futex.2.html
Parameters
| Name | Type | Description |
|---|---|---|
address | *uint32 | the word to wait on, four-byte aligned |
expected | uint32 | the value the caller last saw there |
timeout | *Timespec | how long to wait at most, relative to now, or null to wait without a limit |
Returns: zero after a wake, or a negative error number: EAGAIN, EINTR or ETIMEDOUT
FutexWake
pub func FutexWake(address: *uint32, count: int32) -> int64
Wakes up to count threads sleeping on address.
See also: https://man7.org/linux/man-pages/man2/futex.2.html
Parameters
| Name | Type | Description |
|---|---|---|
address | *uint32 | the word they wait on |
count | int32 | how many to wake at most |
Returns: how many were woken, or a negative error number