Skip to content

Commit 7c28791

Browse files
committed
Add doc comments to futex operations.
1 parent 307aa58 commit 7c28791

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

library/std/src/sys/unix/futex.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
use crate::sync::atomic::AtomicI32;
88
use crate::time::Duration;
99

10+
/// Wait for a futex_wake operation to wake us.
11+
///
12+
/// Returns directly if the futex doesn't hold the expected value.
13+
///
14+
/// Returns false on timeout, and true in all other cases.
1015
#[cfg(any(target_os = "linux", target_os = "android"))]
1116
pub fn futex_wait(futex: &AtomicI32, expected: i32, timeout: Option<Duration>) -> bool {
1217
use super::time::Timespec;
@@ -68,6 +73,10 @@ pub fn futex_wait(futex: &AtomicI32, expected: i32, timeout: Option<Duration>) {
6873
}
6974
}
7075

76+
/// Wake up one thread that's blocked on futex_wait on this futex.
77+
///
78+
/// Returns true if this actually woke up such a thread,
79+
/// or false if no thread was waiting on this futex.
7180
#[cfg(any(target_os = "linux", target_os = "android"))]
7281
pub fn futex_wake(futex: &AtomicI32) -> bool {
7382
unsafe {
@@ -80,6 +89,7 @@ pub fn futex_wake(futex: &AtomicI32) -> bool {
8089
}
8190
}
8291

92+
/// Wake up all threads that are waiting on futex_wait on this futex.
8393
#[cfg(any(target_os = "linux", target_os = "android"))]
8494
pub fn futex_wake_all(futex: &AtomicI32) {
8595
unsafe {

0 commit comments

Comments
 (0)