Skip to content

Commit 021bea1

Browse files
committed
auto merge of #14813 : cmr/rust/once-docs-unsafe, r=alexcrichton
2 parents 3a9228b + 8472849 commit 021bea1

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
@@ -20,22 +20,18 @@ use core::atomics;
2020

2121
use mutex::{StaticMutex, MUTEX_INIT};
2222

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

0 commit comments

Comments
 (0)