Rollup merge of #68945 - mjbshaw:once_is_completed, r=LukasKalbertodt
Stabilize Once::is_completed Closes #54890 This function has been around for some time. I haven't seen anyone raise any objections to it. I've personally found it useful myself. It would be nice to finally stabilize it and
This commit is contained in:
commit
588f00841b
|
@ -331,14 +331,14 @@ impl Once {
|
||||||
/// * `call_once` was called, but has not yet completed,
|
/// * `call_once` was called, but has not yet completed,
|
||||||
/// * the `Once` instance is poisoned
|
/// * the `Once` instance is poisoned
|
||||||
///
|
///
|
||||||
/// It is also possible that immediately after `is_completed`
|
/// This function returning `false` does not mean that `Once` has not been
|
||||||
/// returns false, some other thread finishes executing
|
/// executed. For example, it may have been executed in the time between
|
||||||
/// `call_once`.
|
/// when `is_completed` starts executing and when it returns, in which case
|
||||||
|
/// the `false` return value would be stale (but still permissible).
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// #![feature(once_is_completed)]
|
|
||||||
/// use std::sync::Once;
|
/// use std::sync::Once;
|
||||||
///
|
///
|
||||||
/// static INIT: Once = Once::new();
|
/// static INIT: Once = Once::new();
|
||||||
|
@ -351,7 +351,6 @@ impl Once {
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// #![feature(once_is_completed)]
|
|
||||||
/// use std::sync::Once;
|
/// use std::sync::Once;
|
||||||
/// use std::thread;
|
/// use std::thread;
|
||||||
///
|
///
|
||||||
|
@ -364,7 +363,7 @@ impl Once {
|
||||||
/// assert!(handle.join().is_err());
|
/// assert!(handle.join().is_err());
|
||||||
/// assert_eq!(INIT.is_completed(), false);
|
/// assert_eq!(INIT.is_completed(), false);
|
||||||
/// ```
|
/// ```
|
||||||
#[unstable(feature = "once_is_completed", issue = "54890")]
|
#[stable(feature = "once_is_completed", since = "1.44.0")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_completed(&self) -> bool {
|
pub fn is_completed(&self) -> bool {
|
||||||
// An `Acquire` load is enough because that makes all the initialization
|
// An `Acquire` load is enough because that makes all the initialization
|
||||||
|
|
Loading…
Reference in New Issue