diff options
| -rw-r--r-- | library/std/src/sys/sync/once/futex.rs | 2 | ||||
| -rw-r--r-- | library/std/src/sys/sync/once/queue.rs | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/library/std/src/sys/sync/once/futex.rs b/library/std/src/sys/sync/once/futex.rs index 827bbf014cd..407fdcebcf5 100644 --- a/library/std/src/sys/sync/once/futex.rs +++ b/library/std/src/sys/sync/once/futex.rs @@ -17,6 +17,8 @@ const POISONED: Primitive = 2; /// so all future threads need to wait for it to finish. const RUNNING: Primitive = 1; /// Initialization has completed and all future calls should finish immediately. +/// By choosing this state as the all-zero state the `is_completed` check can be +/// a bit faster on some platforms. const COMPLETE: Primitive = 0; // An additional bit indicates whether there are waiting threads: diff --git a/library/std/src/sys/sync/once/queue.rs b/library/std/src/sys/sync/once/queue.rs index 7bebb6696a8..49e15d65f25 100644 --- a/library/std/src/sys/sync/once/queue.rs +++ b/library/std/src/sys/sync/once/queue.rs @@ -74,7 +74,8 @@ pub struct OnceState { } // Four states that a Once can be in, encoded into the lower bits of -// `state_and_queue` in the Once structure. +// `state_and_queue` in the Once structure. By choosing COMPLETE as the all-zero +// state the `is_completed` check can be a bit faster on some platforms. const INCOMPLETE: usize = 0x3; const POISONED: usize = 0x2; const RUNNING: usize = 0x1; |
