File tree Expand file tree Collapse file tree 2 files changed +4
-1
lines changed
library/std/src/sys/sync/once Expand file tree Collapse file tree 2 files changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,8 @@ const POISONED: Primitive = 2;
17
17
/// so all future threads need to wait for it to finish.
18
18
const RUNNING : Primitive = 1 ;
19
19
/// Initialization has completed and all future calls should finish immediately.
20
+ /// By choosing this state as the all-zero state the `is_completed` check can be
21
+ /// a bit faster on some platforms.
20
22
const COMPLETE : Primitive = 0 ;
21
23
22
24
// An additional bit indicates whether there are waiting threads:
Original file line number Diff line number Diff line change @@ -74,7 +74,8 @@ pub struct OnceState {
74
74
}
75
75
76
76
// Four states that a Once can be in, encoded into the lower bits of
77
- // `state_and_queue` in the Once structure.
77
+ // `state_and_queue` in the Once structure. By choosing COMPLETE as the all-zero
78
+ // state the `is_completed` check can be a bit faster on some platforms.
78
79
const INCOMPLETE : usize = 0x3 ;
79
80
const POISONED : usize = 0x2 ;
80
81
const RUNNING : usize = 0x1 ;
You can’t perform that action at this time.
0 commit comments