Available on crate feature
thread only.Expand description
Linux futex.
Futex is a very low-level mechanism for implementing concurrency primitives such as mutexes, rwlocks, and condvars. For a higher-level API that provides those abstractions, see rustix-futex-sync.
§Examples
use rustix::thread::futex;
use std::sync::atomic::AtomicU32;
// Wake up one waiter.
futex::wake(futex, futex::Flags::PRIVATE, 1)?;§References
Structs§
- Flags
FUTEX_*flags for use with the functions infutex.- Timespec
struct timespec—A quantity of time in seconds plus nanoseconds.- Wait
- For use with
waitv. - Wait
Flags FUTEX2_*flags for use with the functions inWaitv.- WaitPtr
- A pointer in the
Waitstruct. - Waitv
Flags - Flags for use with the flags argument in
waitv.
Enums§
- ClockId
CLOCK_*constants for use withclock_gettime.- WakeOp
FUTEX_OP_*operations for use withwake_op.- Wake
OpCmp FUTEX_OP_CMP_*operations for use withwake_op.
Constants§
- OWNER_
DIED FUTEX_OWNER_DIED- WAITERS
FUTEX_WAITERS
Functions§
- cmp_
requeue syscall(SYS_futex, uaddr, FUTEX_CMP_REQUEUE, val, val2, uaddr2, val3)- cmp_
requeue_ pi syscall(SYS_futex, uaddr, FUTEX_CMP_REQUEUE_PI, 1, val2, uaddr2, val3)- fd
syscall(SYS_futex, uaddr, FUTEX_FD, val, NULL, NULL, 0)- lock_pi
syscall(SYS_futex, uaddr, FUTEX_LOCK_PI, 0, timeout, NULL, 0)- lock_
pi2 syscall(SYS_futex, uaddr, FUTEX_LOCK_PI2, 0, timeout, NULL, 0)- requeue
syscall(SYS_futex, uaddr, FUTEX_REQUEUE, val, val2, uaddr2, 0)- trylock_
pi syscall(SYS_futex, uaddr, FUTEX_TRYLOCK_PI, 0, NULL, NULL, 0)- unlock_
pi syscall(SYS_futex, uaddr, FUTEX_UNLOCK_PI, 0, NULL, NULL, 0)- wait
syscall(SYS_futex, uaddr, FUTEX_WAIT, val, timeout, NULL, 0)- wait_
bitset syscall(SYS_futex, uaddr, FUTEX_WAIT_BITSET, val, timeout, NULL, val3)- wait_
requeue_ pi syscall(SYS_futex, uaddr, FUTEX_WAIT_REQUEUE_PI, val, timeout, uaddr2, 0)- waitv
futex_waitv(waiters.as_ptr(), waiters.len(), flags, timeout, clockd)— Wait on an array of futexes, wake on any.- wake
syscall(SYS_futex, uaddr, FUTEX_WAKE, val, NULL, NULL, 0)- wake_
bitset syscall(SYS_futex, uaddr, FUTEX_WAKE_BITSET, val, NULL, NULL, val3)- wake_op
syscall(SYS_futex, uaddr, FUTEX_WAKE_OP, val, val2, uaddr2, val3)