@@ -2,10 +2,10 @@ use core::sync::atomic::{AtomicUsize, Ordering::Relaxed};
2
2
3
3
// This structure represents a lazily initialized static usize value. Useful
4
4
// when it is preferable to just rerun initialization instead of locking.
5
- // Both unsync_init and sync_init will invoke an init() function until it
6
- // succeeds, then return the cached value for future calls.
5
+ // unsync_init will invoke an init() function until it succeeds, then return the
6
+ // cached value for future calls.
7
7
//
8
- // Both methods support init() "failing". If the init() method returns UNINIT,
8
+ // unsync_init supports init() "failing". If the init() method returns UNINIT,
9
9
// that value will be returned as normal, but will not be cached.
10
10
//
11
11
// Users should only depend on the _value_ returned by init() functions.
@@ -17,7 +17,7 @@ use core::sync::atomic::{AtomicUsize, Ordering::Relaxed};
17
17
// v
18
18
// }
19
19
// the effects of c() or writes to shared memory will not necessarily be
20
- // observed and additional synchronization methods with be needed.
20
+ // observed and additional synchronization methods may be needed.
21
21
pub ( crate ) struct LazyUsize ( AtomicUsize ) ;
22
22
23
23
impl LazyUsize {
@@ -28,8 +28,8 @@ impl LazyUsize {
28
28
// The initialization is not completed.
29
29
pub const UNINIT : usize = usize:: max_value ( ) ;
30
30
31
- // Runs the init() function at least once, returning the value of some run
32
- // of init(). Multiple callers can run their init() functions in parallel.
31
+ // Runs the init() function at most once, returning the value of some run of
32
+ // init(). Multiple callers can run their init() functions in parallel.
33
33
// init() should always return the same value, if it succeeds.
34
34
pub fn unsync_init ( & self , init : impl FnOnce ( ) -> usize ) -> usize {
35
35
// Relaxed ordering is fine, as we only have a single atomic variable.
0 commit comments