diff options
| author | Paul Menage <menage@gmail.com> | 2024-10-17 12:21:53 -0700 |
|---|---|---|
| committer | Paul Menage <menage@gmail.com> | 2024-10-17 12:21:53 -0700 |
| commit | cf7ff15a0ddfe0713dd794cd39eb3b3b58ba8d27 (patch) | |
| tree | 4b14a1e05b6fca5c17fc010616fc9547ac143651 /library/std/src/sys/sync/condvar/futex.rs | |
| parent | 3a85d3fa785d95a7b7bcf4f160b67bffba7afd4a (diff) | |
| download | rust-cf7ff15a0ddfe0713dd794cd39eb3b3b58ba8d27.tar.gz rust-cf7ff15a0ddfe0713dd794cd39eb3b3b58ba8d27.zip | |
Abstract the state type for futexes
In the same way that we expose SmallAtomic and SmallPrimitive to allow
Windows to use a value other than an AtomicU32 for its futex state, this
patch switches the primary futex state type from AtomicU32 to
futex::Atomic. The futex::Atomic type should be usable as an atomic
value with underlying primitive type equal to futex::Primitive.
This allows supporting the futex API on systems where the underlying
kernel futex implementation requires more state than simply an
AtomicU32.
All in-tree futex implementations simply define {Atomic,Primitive}
directly as {AtomicU32,u32}.
Diffstat (limited to 'library/std/src/sys/sync/condvar/futex.rs')
| -rw-r--r-- | library/std/src/sys/sync/condvar/futex.rs | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/library/std/src/sys/sync/condvar/futex.rs b/library/std/src/sys/sync/condvar/futex.rs index 39cd97c01ea..0d0c5f0dbe7 100644 --- a/library/std/src/sys/sync/condvar/futex.rs +++ b/library/std/src/sys/sync/condvar/futex.rs @@ -1,6 +1,5 @@ -use crate::sync::atomic::AtomicU32; use crate::sync::atomic::Ordering::Relaxed; -use crate::sys::futex::{futex_wait, futex_wake, futex_wake_all}; +use crate::sys::futex::{Futex, futex_wait, futex_wake, futex_wake_all}; use crate::sys::sync::Mutex; use crate::time::Duration; @@ -8,13 +7,13 @@ pub struct Condvar { // The value of this atomic is simply incremented on every notification. // This is used by `.wait()` to not miss any notifications after // unlocking the mutex and before waiting for notifications. - futex: AtomicU32, + futex: Futex, } impl Condvar { #[inline] pub const fn new() -> Self { - Self { futex: AtomicU32::new(0) } + Self { futex: Futex::new(0) } } // All the memory orderings here are `Relaxed`, |
