atomic_wait/
lib.rs

1#![no_std]
2#![doc = include_str!("../README.md")]
3
4use core::sync::atomic::AtomicU32;
5
6#[cfg(any(target_os = "linux", target_os = "android"))]
7#[path = "linux.rs"]
8mod platform;
9
10#[cfg(any(target_os = "macos", target_os = "ios", target_os = "watchos"))]
11#[path = "macos.rs"]
12mod platform;
13
14#[cfg(windows)]
15#[path = "windows.rs"]
16mod platform;
17
18#[cfg(target_os = "freebsd")]
19#[path = "freebsd.rs"]
20mod platform;
21
22/// If the value is `value`, wait until woken up.
23///
24/// This function might also return spuriously,
25/// without a corresponding wake operation.
26#[inline]
27pub fn wait(atomic: &AtomicU32, value: u32) {
28    platform::wait(atomic, value)
29}
30
31/// Wake one thread that is waiting on this atomic.
32///
33/// It's okay if the pointer dangles or is null.
34#[inline]
35pub fn wake_one(atomic: *const AtomicU32) {
36    platform::wake_one(atomic);
37}
38
39/// Wake all threads that are waiting on this atomic.
40///
41/// It's okay if the pointer dangles or is null.
42#[inline]
43pub fn wake_all(atomic: *const AtomicU32) {
44    platform::wake_all(atomic);
45}