@@ -95,11 +95,9 @@ use crate::thread::{self, Thread};
95
95
96
96
/// A synchronization primitive which can be used to run a one-time global
97
97
/// initialization. Useful for one-time initialization for FFI or related
98
- /// functionality. This type can only be constructed with the [`Once::new`]
98
+ /// functionality. This type can only be constructed with the [`Once::new() `]
99
99
/// constructor.
100
100
///
101
- /// [`Once::new`]: struct.Once.html#method.new
102
- ///
103
101
/// # Examples
104
102
///
105
103
/// ```
@@ -126,11 +124,8 @@ unsafe impl Sync for Once {}
126
124
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
127
125
unsafe impl Send for Once { }
128
126
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
127
+ /// State yielded to [`Once::call_once_force()`]’s closure parameter. The state
128
+ /// can be used to query the poison status of the [`Once`].
134
129
#[ unstable( feature = "once_poison" , issue = "33577" ) ]
135
130
#[ derive( Debug ) ]
136
131
pub struct OnceState {
@@ -140,8 +135,6 @@ pub struct OnceState {
140
135
141
136
/// Initialization value for static [`Once`] values.
142
137
///
143
- /// [`Once`]: struct.Once.html
144
- ///
145
138
/// # Examples
146
139
///
147
140
/// ```
@@ -212,7 +205,7 @@ impl Once {
212
205
/// happens-before relation between the closure and code executing after the
213
206
/// return).
214
207
///
215
- /// If the given closure recursively invokes `call_once` on the same `Once`
208
+ /// If the given closure recursively invokes `call_once` on the same [ `Once`]
216
209
/// instance the exact behavior is not specified, allowed outcomes are
217
210
/// a panic or a deadlock.
218
211
///
@@ -249,7 +242,7 @@ impl Once {
249
242
///
250
243
/// The closure `f` will only be executed once if this is called
251
244
/// concurrently amongst many threads. If that closure panics, however, then
252
- /// it will *poison* this `Once` instance, causing all future invocations of
245
+ /// it will *poison* this [ `Once`] instance, causing all future invocations of
253
246
/// `call_once` to also panic.
254
247
///
255
248
/// This is similar to [poisoning with mutexes][poison].
@@ -269,21 +262,21 @@ impl Once {
269
262
self . call_inner ( false , & mut |_| f. take ( ) . unwrap ( ) ( ) ) ;
270
263
}
271
264
272
- /// Performs the same function as [`call_once`] except ignores poisoning.
265
+ /// Performs the same function as [`call_once() `] except ignores poisoning.
273
266
///
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.
267
+ /// Unlike [`call_once() `], if this [ `Once`] has been poisoned (i.e., a previous
268
+ /// call to [ `call_once()`] or [ `call_once_force()`] caused a panic), calling
269
+ /// [ `call_once_force()`] will still invoke the closure `f` and will _not_
270
+ /// result in an immediate panic. If `f` panics, the [ `Once`] will remain
271
+ /// in a poison state. If `f` does _not_ panic, the [ `Once`] will no
272
+ /// longer be in a poison state and all future calls to [ `call_once()`] or
273
+ /// [ `call_once_force()`] will be no-ops.
281
274
///
282
275
/// The closure `f` is yielded a [`OnceState`] structure which can be used
283
- /// to query the poison status of the `Once`.
276
+ /// to query the poison status of the [ `Once`] .
284
277
///
285
- /// [`call_once`]: struct. Once.html#method. call_once
286
- /// [`OnceState `]: struct.OnceState.html
278
+ /// [`call_once() `]: Once:: call_once
279
+ /// [`call_once_force() `]: Once::call_once_force
287
280
///
288
281
/// # Examples
289
282
///
@@ -329,18 +322,20 @@ impl Once {
329
322
self . call_inner ( true , & mut |p| f. take ( ) . unwrap ( ) ( p) ) ;
330
323
}
331
324
332
- /// Returns `true` if some `call_once` call has completed
325
+ /// Returns `true` if some [ `call_once()`] call has completed
333
326
/// successfully. Specifically, `is_completed` will return false in
334
327
/// 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
328
+ /// * [ `call_once()`] was not called at all,
329
+ /// * [ `call_once()`] was called, but has not yet completed,
330
+ /// * the [ `Once`] instance is poisoned
338
331
///
339
- /// This function returning `false` does not mean that `Once` has not been
332
+ /// This function returning `false` does not mean that [ `Once`] has not been
340
333
/// executed. For example, it may have been executed in the time between
341
334
/// when `is_completed` starts executing and when it returns, in which case
342
335
/// the `false` return value would be stale (but still permissible).
343
336
///
337
+ /// [`call_once()`]: Once::call_once
338
+ ///
344
339
/// # Examples
345
340
///
346
341
/// ```
@@ -519,14 +514,11 @@ impl Drop for WaiterQueue<'_> {
519
514
520
515
impl OnceState {
521
516
/// 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
517
+ /// invocation of the closure passed to [`Once::call_once_force()`].
526
518
///
527
519
/// # Examples
528
520
///
529
- /// A poisoned `Once`:
521
+ /// A poisoned [ `Once`] :
530
522
///
531
523
/// ```
532
524
/// #![feature(once_poison)]
@@ -547,7 +539,7 @@ impl OnceState {
547
539
/// });
548
540
/// ```
549
541
///
550
- /// An unpoisoned `Once`:
542
+ /// An unpoisoned [ `Once`] :
551
543
///
552
544
/// ```
553
545
/// #![feature(once_poison)]
@@ -565,8 +557,6 @@ impl OnceState {
565
557
}
566
558
567
559
/// Poison the associated [`Once`] without explicitly panicking.
568
- ///
569
- /// [`Once`]: struct.Once.html
570
560
// NOTE: This is currently only exposed for the `lazy` module
571
561
pub ( crate ) fn poison ( & self ) {
572
562
self . set_state_on_drop_to . set ( POISONED ) ;
0 commit comments