Finish moving to intra doc links for std::sync

This commit is contained in:
Alexis Bourget 2020-09-18 11:09:36 +02:00
parent f3c923a13a
commit bffd2111f7
2 changed files with 34 additions and 51 deletions

View File

@ -43,11 +43,8 @@ struct BarrierState {
generation_id: usize, generation_id: usize,
} }
/// A `BarrierWaitResult` is returned by [`wait`] when all threads in the [`Barrier`] /// A `BarrierWaitResult` is returned by [`Barrier::wait()`] when all threads
/// have rendezvoused. /// in the [`Barrier`] have rendezvoused.
///
/// [`wait`]: struct.Barrier.html#method.wait
/// [`Barrier`]: struct.Barrier.html
/// ///
/// # Examples /// # Examples
/// ///
@ -70,10 +67,10 @@ impl fmt::Debug for Barrier {
impl Barrier { impl Barrier {
/// Creates a new barrier that can block a given number of threads. /// Creates a new barrier that can block a given number of threads.
/// ///
/// A barrier will block `n`-1 threads which call [`wait`] and then wake up /// A barrier will block `n`-1 threads which call [`wait()`] and then wake
/// all threads at once when the `n`th thread calls [`wait`]. /// up all threads at once when the `n`th thread calls [`wait()`].
/// ///
/// [`wait`]: #method.wait /// [`wait()`]: Barrier::wait
/// ///
/// # Examples /// # Examples
/// ///
@ -99,10 +96,7 @@ impl Barrier {
/// A single (arbitrary) thread will receive a [`BarrierWaitResult`] that /// A single (arbitrary) thread will receive a [`BarrierWaitResult`] that
/// returns `true` from [`is_leader`] when returning from this function, and /// returns `true` from [`is_leader`] when returning from this function, and
/// all other threads will receive a result that will return `false` from /// all other threads will receive a result that will return `false` from
/// [`is_leader`]. /// [`BarrierWaitResult::is_leader`].
///
/// [`BarrierWaitResult`]: struct.BarrierWaitResult.html
/// [`is_leader`]: struct.BarrierWaitResult.html#method.is_leader
/// ///
/// # Examples /// # Examples
/// ///
@ -156,13 +150,12 @@ impl fmt::Debug for BarrierWaitResult {
} }
impl BarrierWaitResult { impl BarrierWaitResult {
/// Returns `true` if this thread from [`wait`] is the "leader thread". /// Returns `true` if this thread from [`Barrier::wait()`] is the
/// "leader thread".
/// ///
/// Only one thread will have `true` returned from their result, all other /// Only one thread will have `true` returned from their result, all other
/// threads will have `false` returned. /// threads will have `false` returned.
/// ///
/// [`wait`]: struct.Barrier.html#method.wait
///
/// # Examples /// # Examples
/// ///
/// ``` /// ```

View File

@ -95,11 +95,9 @@ use crate::thread::{self, Thread};
/// A synchronization primitive which can be used to run a one-time global /// A synchronization primitive which can be used to run a one-time global
/// initialization. Useful for one-time initialization for FFI or related /// initialization. Useful for one-time initialization for FFI or related
/// functionality. This type can only be constructed with the [`Once::new`] /// functionality. This type can only be constructed with the [`Once::new()`]
/// constructor. /// constructor.
/// ///
/// [`Once::new`]: struct.Once.html#method.new
///
/// # Examples /// # Examples
/// ///
/// ``` /// ```
@ -126,11 +124,8 @@ unsafe impl Sync for Once {}
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
unsafe impl Send for Once {} unsafe impl Send for Once {}
/// State yielded to [`call_once_force`]s closure parameter. The state can be /// State yielded to [`Once::call_once_force()`]s closure parameter. The state
/// used to query the poison status of the [`Once`]. /// can be used to query the poison status of the [`Once`].
///
/// [`call_once_force`]: struct.Once.html#method.call_once_force
/// [`Once`]: struct.Once.html
#[unstable(feature = "once_poison", issue = "33577")] #[unstable(feature = "once_poison", issue = "33577")]
#[derive(Debug)] #[derive(Debug)]
pub struct OnceState { pub struct OnceState {
@ -140,8 +135,6 @@ pub struct OnceState {
/// Initialization value for static [`Once`] values. /// Initialization value for static [`Once`] values.
/// ///
/// [`Once`]: struct.Once.html
///
/// # Examples /// # Examples
/// ///
/// ``` /// ```
@ -212,7 +205,7 @@ impl Once {
/// happens-before relation between the closure and code executing after the /// happens-before relation between the closure and code executing after the
/// return). /// return).
/// ///
/// If the given closure recursively invokes `call_once` on the same `Once` /// If the given closure recursively invokes `call_once` on the same [`Once`]
/// instance the exact behavior is not specified, allowed outcomes are /// instance the exact behavior is not specified, allowed outcomes are
/// a panic or a deadlock. /// a panic or a deadlock.
/// ///
@ -249,7 +242,7 @@ impl Once {
/// ///
/// The closure `f` will only be executed once if this is called /// The closure `f` will only be executed once if this is called
/// concurrently amongst many threads. If that closure panics, however, then /// concurrently amongst many threads. If that closure panics, however, then
/// it will *poison* this `Once` instance, causing all future invocations of /// it will *poison* this [`Once`] instance, causing all future invocations of
/// `call_once` to also panic. /// `call_once` to also panic.
/// ///
/// This is similar to [poisoning with mutexes][poison]. /// This is similar to [poisoning with mutexes][poison].
@ -269,21 +262,21 @@ impl Once {
self.call_inner(false, &mut |_| f.take().unwrap()()); self.call_inner(false, &mut |_| f.take().unwrap()());
} }
/// Performs the same function as [`call_once`] except ignores poisoning. /// Performs the same function as [`call_once()`] except ignores poisoning.
/// ///
/// Unlike [`call_once`], if this `Once` has been poisoned (i.e., a previous /// Unlike [`call_once()`], if this [`Once`] has been poisoned (i.e., a previous
/// call to `call_once` or `call_once_force` caused a panic), calling /// call to [`call_once()`] or [`call_once_force()`] caused a panic), calling
/// `call_once_force` will still invoke the closure `f` and will _not_ /// [`call_once_force()`] will still invoke the closure `f` and will _not_
/// result in an immediate panic. If `f` panics, the `Once` will remain /// result in an immediate panic. If `f` panics, the [`Once`] will remain
/// in a poison state. If `f` does _not_ panic, the `Once` will no /// in a poison state. If `f` does _not_ panic, the [`Once`] will no
/// longer be in a poison state and all future calls to `call_once` or /// longer be in a poison state and all future calls to [`call_once()`] or
/// `call_once_force` will be no-ops. /// [`call_once_force()`] will be no-ops.
/// ///
/// The closure `f` is yielded a [`OnceState`] structure which can be used /// The closure `f` is yielded a [`OnceState`] structure which can be used
/// to query the poison status of the `Once`. /// to query the poison status of the [`Once`].
/// ///
/// [`call_once`]: struct.Once.html#method.call_once /// [`call_once()`]: Once::call_once
/// [`OnceState`]: struct.OnceState.html /// [`call_once_force()`]: Once::call_once_force
/// ///
/// # Examples /// # Examples
/// ///
@ -329,18 +322,20 @@ impl Once {
self.call_inner(true, &mut |p| f.take().unwrap()(p)); self.call_inner(true, &mut |p| f.take().unwrap()(p));
} }
/// Returns `true` if some `call_once` call has completed /// Returns `true` if some [`call_once()`] call has completed
/// successfully. Specifically, `is_completed` will return false in /// successfully. Specifically, `is_completed` will return false in
/// the following situations: /// the following situations:
/// * `call_once` was not called at all, /// * [`call_once()`] was not called at all,
/// * `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
/// ///
/// This function returning `false` does not mean that `Once` has not been /// This function returning `false` does not mean that [`Once`] has not been
/// executed. For example, it may have been executed in the time between /// executed. For example, it may have been executed in the time between
/// when `is_completed` starts executing and when it returns, in which case /// when `is_completed` starts executing and when it returns, in which case
/// the `false` return value would be stale (but still permissible). /// the `false` return value would be stale (but still permissible).
/// ///
/// [`call_once()`]: Once::call_once
///
/// # Examples /// # Examples
/// ///
/// ``` /// ```
@ -519,14 +514,11 @@ impl Drop for WaiterQueue<'_> {
impl OnceState { impl OnceState {
/// Returns `true` if the associated [`Once`] was poisoned prior to the /// Returns `true` if the associated [`Once`] was poisoned prior to the
/// invocation of the closure passed to [`call_once_force`]. /// invocation of the closure passed to [`Once::call_once_force()`].
///
/// [`call_once_force`]: struct.Once.html#method.call_once_force
/// [`Once`]: struct.Once.html
/// ///
/// # Examples /// # Examples
/// ///
/// A poisoned `Once`: /// A poisoned [`Once`]:
/// ///
/// ``` /// ```
/// #![feature(once_poison)] /// #![feature(once_poison)]
@ -547,7 +539,7 @@ impl OnceState {
/// }); /// });
/// ``` /// ```
/// ///
/// An unpoisoned `Once`: /// An unpoisoned [`Once`]:
/// ///
/// ``` /// ```
/// #![feature(once_poison)] /// #![feature(once_poison)]
@ -565,8 +557,6 @@ impl OnceState {
} }
/// Poison the associated [`Once`] without explicitly panicking. /// Poison the associated [`Once`] without explicitly panicking.
///
/// [`Once`]: struct.Once.html
// NOTE: This is currently only exposed for the `lazy` module // NOTE: This is currently only exposed for the `lazy` module
pub(crate) fn poison(&self) { pub(crate) fn poison(&self) {
self.set_state_on_drop_to.set(POISONED); self.set_state_on_drop_to.set(POISONED);