Skip to content

Commit 2e4bb4d

Browse files
authoredJan 17, 2024
Correct comments regarding LazyUsize (#391)
1 parent f68a940 commit 2e4bb4d

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed
 

‎src/lazy.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ use core::sync::atomic::{AtomicUsize, Ordering::Relaxed};
22

33
// This structure represents a lazily initialized static usize value. Useful
44
// 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.
77
//
8-
// Both methods support init() "failing". If the init() method returns UNINIT,
8+
// unsync_init supports init() "failing". If the init() method returns UNINIT,
99
// that value will be returned as normal, but will not be cached.
1010
//
1111
// Users should only depend on the _value_ returned by init() functions.
@@ -17,7 +17,7 @@ use core::sync::atomic::{AtomicUsize, Ordering::Relaxed};
1717
// v
1818
// }
1919
// 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.
2121
pub(crate) struct LazyUsize(AtomicUsize);
2222

2323
impl LazyUsize {
@@ -28,8 +28,8 @@ impl LazyUsize {
2828
// The initialization is not completed.
2929
pub const UNINIT: usize = usize::max_value();
3030

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.
3333
// init() should always return the same value, if it succeeds.
3434
pub fn unsync_init(&self, init: impl FnOnce() -> usize) -> usize {
3535
// Relaxed ordering is fine, as we only have a single atomic variable.

0 commit comments

Comments
 (0)