| Crates.io | wait_on_address |
| lib.rs | wait_on_address |
| version | 0.1.4 |
| created_at | 2025-10-09 22:32:05.280729+00 |
| updated_at | 2026-01-11 02:27:17.930849+00 |
| description | Cross-platform atomic wait and wake (aka futex) functionality. |
| homepage | |
| repository | https://github.com/DouglasDwyer/wait_on_address |
| max_upload_size | |
| id | 1876259 |
| size | 40,215 |
Cross platform atomic wait and wake (aka futex) functionality. This crate is a fork of atomic-wait, and extends the original code with the following functionality:
AtomicI32, AtomicI64, and AtomicU64wasm32 on nightly using std::archNatively-supported platforms:
std support (using fallback)use std::{sync::atomic::AtomicU64, time::Duration};
use wait_on_address::AtomicWait;
let a = AtomicU64::new(0);
a.wait(1); // If the value is 1, wait.
a.wait_timeout(2, Duration::from_millis(100)); // If the value is 2, wait at most 100 milliseconds
a.notify_one(); // Wake one waiting thread.
a.notify_all(); // Wake all waiting threads.
On Linux, this uses the SYS_futex syscall.
On FreeBSD, this uses the _umtx_op syscall.
On Windows, this uses the WaitOnAddress and WakeByAddress APIs.
On macOS (and iOS and watchOS), this uses the os_sync_wait_on_address and os_sync_wake_by_address APIs.
On wasm32 with nightly, this uses memory_atomic_wait32, memory_atomic_wait64, and memory_atomic_notify instructions.
All other platforms with std support fall back to a fixed-size hashmap of Condvars, similar to libstdc++'s implementation for std::atomic<T>.