Skip to content

Commit 0f5f2e4

Browse files
authored
Rollup merge of rust-lang#76868 - poliorcetics:intra-doc-std-sync, r=jyn514
Finish moving to intra doc links for std::sync Helps with rust-lang#75080. @rustbot modify labels: T-doc A-intra-doc-links r? @jyn514
2 parents de4f13c + aaddcdb commit 0f5f2e4

File tree

2 files changed

+36
-54
lines changed

2 files changed

+36
-54
lines changed

library/std/src/sync/barrier.rs

+10-17
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,8 @@ struct BarrierState {
4343
generation_id: usize,
4444
}
4545

46-
/// A `BarrierWaitResult` is returned by [`wait`] when all threads in the [`Barrier`]
47-
/// have rendezvoused.
48-
///
49-
/// [`wait`]: struct.Barrier.html#method.wait
50-
/// [`Barrier`]: struct.Barrier.html
46+
/// A `BarrierWaitResult` is returned by [`Barrier::wait()`] when all threads
47+
/// in the [`Barrier`] have rendezvoused.
5148
///
5249
/// # Examples
5350
///
@@ -70,10 +67,10 @@ impl fmt::Debug for Barrier {
7067
impl Barrier {
7168
/// Creates a new barrier that can block a given number of threads.
7269
///
73-
/// A barrier will block `n`-1 threads which call [`wait`] and then wake up
74-
/// all threads at once when the `n`th thread calls [`wait`].
70+
/// A barrier will block `n`-1 threads which call [`wait()`] and then wake
71+
/// up all threads at once when the `n`th thread calls [`wait()`].
7572
///
76-
/// [`wait`]: #method.wait
73+
/// [`wait()`]: Barrier::wait
7774
///
7875
/// # Examples
7976
///
@@ -97,12 +94,9 @@ impl Barrier {
9794
/// be used continuously.
9895
///
9996
/// A single (arbitrary) thread will receive a [`BarrierWaitResult`] that
100-
/// returns `true` from [`is_leader`] when returning from this function, and
101-
/// all other threads will receive a result that will return `false` from
102-
/// [`is_leader`].
103-
///
104-
/// [`BarrierWaitResult`]: struct.BarrierWaitResult.html
105-
/// [`is_leader`]: struct.BarrierWaitResult.html#method.is_leader
97+
/// returns `true` from [`BarrierWaitResult::is_leader()`] when returning
98+
/// from this function, and all other threads will receive a result that
99+
/// will return `false` from [`BarrierWaitResult::is_leader()`].
106100
///
107101
/// # Examples
108102
///
@@ -156,13 +150,12 @@ impl fmt::Debug for BarrierWaitResult {
156150
}
157151

158152
impl BarrierWaitResult {
159-
/// Returns `true` if this thread from [`wait`] is the "leader thread".
153+
/// Returns `true` if this thread is the "leader thread" for the call to
154+
/// [`Barrier::wait()`].
160155
///
161156
/// Only one thread will have `true` returned from their result, all other
162157
/// threads will have `false` returned.
163158
///
164-
/// [`wait`]: struct.Barrier.html#method.wait
165-
///
166159
/// # Examples
167160
///
168161
/// ```

library/std/src/sync/once.rs

+26-37
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,7 @@ use crate::thread::{self, Thread};
9595

9696
/// A synchronization primitive which can be used to run a one-time global
9797
/// initialization. Useful for one-time initialization for FFI or related
98-
/// functionality. This type can only be constructed with the [`Once::new`]
99-
/// constructor.
100-
///
101-
/// [`Once::new`]: struct.Once.html#method.new
98+
/// functionality. This type can only be constructed with [`Once::new()`].
10299
///
103100
/// # Examples
104101
///
@@ -126,11 +123,8 @@ unsafe impl Sync for Once {}
126123
#[stable(feature = "rust1", since = "1.0.0")]
127124
unsafe impl Send for Once {}
128125

129-
/// State yielded to [`call_once_force`]’s closure parameter. The state can be
130-
/// used to query the poison status of the [`Once`].
131-
///
132-
/// [`call_once_force`]: struct.Once.html#method.call_once_force
133-
/// [`Once`]: struct.Once.html
126+
/// State yielded to [`Once::call_once_force()`]’s closure parameter. The state
127+
/// can be used to query the poison status of the [`Once`].
134128
#[unstable(feature = "once_poison", issue = "33577")]
135129
#[derive(Debug)]
136130
pub struct OnceState {
@@ -140,8 +134,6 @@ pub struct OnceState {
140134

141135
/// Initialization value for static [`Once`] values.
142136
///
143-
/// [`Once`]: struct.Once.html
144-
///
145137
/// # Examples
146138
///
147139
/// ```
@@ -212,7 +204,7 @@ impl Once {
212204
/// happens-before relation between the closure and code executing after the
213205
/// return).
214206
///
215-
/// If the given closure recursively invokes `call_once` on the same `Once`
207+
/// If the given closure recursively invokes `call_once` on the same [`Once`]
216208
/// instance the exact behavior is not specified, allowed outcomes are
217209
/// a panic or a deadlock.
218210
///
@@ -249,7 +241,7 @@ impl Once {
249241
///
250242
/// The closure `f` will only be executed once if this is called
251243
/// concurrently amongst many threads. If that closure panics, however, then
252-
/// it will *poison* this `Once` instance, causing all future invocations of
244+
/// it will *poison* this [`Once`] instance, causing all future invocations of
253245
/// `call_once` to also panic.
254246
///
255247
/// This is similar to [poisoning with mutexes][poison].
@@ -269,21 +261,21 @@ impl Once {
269261
self.call_inner(false, &mut |_| f.take().unwrap()());
270262
}
271263

272-
/// Performs the same function as [`call_once`] except ignores poisoning.
264+
/// Performs the same function as [`call_once()`] except ignores poisoning.
273265
///
274-
/// Unlike [`call_once`], if this `Once` has been poisoned (i.e., a previous
275-
/// call to `call_once` or `call_once_force` caused a panic), calling
276-
/// `call_once_force` will still invoke the closure `f` and will _not_
277-
/// result in an immediate panic. If `f` panics, the `Once` will remain
278-
/// in a poison state. If `f` does _not_ panic, the `Once` will no
279-
/// longer be in a poison state and all future calls to `call_once` or
280-
/// `call_once_force` will be no-ops.
266+
/// Unlike [`call_once()`], if this [`Once`] has been poisoned (i.e., a previous
267+
/// call to [`call_once()`] or [`call_once_force()`] caused a panic), calling
268+
/// [`call_once_force()`] will still invoke the closure `f` and will _not_
269+
/// result in an immediate panic. If `f` panics, the [`Once`] will remain
270+
/// in a poison state. If `f` does _not_ panic, the [`Once`] will no
271+
/// longer be in a poison state and all future calls to [`call_once()`] or
272+
/// [`call_once_force()`] will be no-ops.
281273
///
282274
/// The closure `f` is yielded a [`OnceState`] structure which can be used
283-
/// to query the poison status of the `Once`.
275+
/// to query the poison status of the [`Once`].
284276
///
285-
/// [`call_once`]: struct.Once.html#method.call_once
286-
/// [`OnceState`]: struct.OnceState.html
277+
/// [`call_once()`]: Once::call_once
278+
/// [`call_once_force()`]: Once::call_once_force
287279
///
288280
/// # Examples
289281
///
@@ -329,18 +321,20 @@ impl Once {
329321
self.call_inner(true, &mut |p| f.take().unwrap()(p));
330322
}
331323

332-
/// Returns `true` if some `call_once` call has completed
324+
/// Returns `true` if some [`call_once()`] call has completed
333325
/// successfully. Specifically, `is_completed` will return false in
334326
/// the following situations:
335-
/// * `call_once` was not called at all,
336-
/// * `call_once` was called, but has not yet completed,
337-
/// * the `Once` instance is poisoned
327+
/// * [`call_once()`] was not called at all,
328+
/// * [`call_once()`] was called, but has not yet completed,
329+
/// * the [`Once`] instance is poisoned
338330
///
339-
/// This function returning `false` does not mean that `Once` has not been
331+
/// This function returning `false` does not mean that [`Once`] has not been
340332
/// executed. For example, it may have been executed in the time between
341333
/// when `is_completed` starts executing and when it returns, in which case
342334
/// the `false` return value would be stale (but still permissible).
343335
///
336+
/// [`call_once()`]: Once::call_once
337+
///
344338
/// # Examples
345339
///
346340
/// ```
@@ -519,14 +513,11 @@ impl Drop for WaiterQueue<'_> {
519513

520514
impl OnceState {
521515
/// Returns `true` if the associated [`Once`] was poisoned prior to the
522-
/// invocation of the closure passed to [`call_once_force`].
523-
///
524-
/// [`call_once_force`]: struct.Once.html#method.call_once_force
525-
/// [`Once`]: struct.Once.html
516+
/// invocation of the closure passed to [`Once::call_once_force()`].
526517
///
527518
/// # Examples
528519
///
529-
/// A poisoned `Once`:
520+
/// A poisoned [`Once`]:
530521
///
531522
/// ```
532523
/// #![feature(once_poison)]
@@ -547,7 +538,7 @@ impl OnceState {
547538
/// });
548539
/// ```
549540
///
550-
/// An unpoisoned `Once`:
541+
/// An unpoisoned [`Once`]:
551542
///
552543
/// ```
553544
/// #![feature(once_poison)]
@@ -565,8 +556,6 @@ impl OnceState {
565556
}
566557

567558
/// Poison the associated [`Once`] without explicitly panicking.
568-
///
569-
/// [`Once`]: struct.Once.html
570559
// NOTE: This is currently only exposed for the `lazy` module
571560
pub(crate) fn poison(&self) {
572561
self.set_state_on_drop_to.set(POISONED);

0 commit comments

Comments
 (0)