Skip to content

Commit 8472849

Browse files
committed
sync: Once is no longer unsafe, update docs
1 parent b1302f9 commit 8472849

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/libsync/one.rs

+6-10
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,18 @@ use std::sync::atomics;
1818

1919
use mutex::{StaticMutex, MUTEX_INIT};
2020

21-
/// A type which can be used to run a one-time global initialization. This type
22-
/// is *unsafe* to use because it is built on top of the `Mutex` in this module.
23-
/// It does not know whether the currently running task is in a green or native
24-
/// context, and a blocking mutex should *not* be used under normal
25-
/// circumstances on a green task.
26-
///
27-
/// Despite its unsafety, it is often useful to have a one-time initialization
28-
/// routine run for FFI bindings or related external functionality. This type
29-
/// can only be statically constructed with the `ONCE_INIT` value.
21+
/// A synchronization primitive which can be used to run a one-time global
22+
/// initialization. Useful for one-time initialization for FFI or related
23+
/// functionality. This type can only be constructed with the `ONCE_INIT`
24+
/// value.
3025
///
3126
/// # Example
3227
///
3328
/// ```rust
3429
/// use sync::one::{Once, ONCE_INIT};
3530
///
3631
/// static mut START: Once = ONCE_INIT;
32+
///
3733
/// unsafe {
3834
/// START.doit(|| {
3935
/// // run initialization here
@@ -58,7 +54,7 @@ impl Once {
5854
/// will be executed if this is the first time `doit` has been called, and
5955
/// otherwise the routine will *not* be invoked.
6056
///
61-
/// This method will block the calling *os thread* if another initialization
57+
/// This method will block the calling task if another initialization
6258
/// routine is currently running.
6359
///
6460
/// When this function returns, it is guaranteed that some initialization

0 commit comments

Comments
 (0)