15
15
//! types.
16
16
//!
17
17
//! This module defines atomic versions of a select number of primitive
18
- //! types, including `AtomicBool`, `AtomicIsize`, and `AtomicUsize`.
18
+ //! types, including [ `AtomicBool`], [ `AtomicIsize`] , and [ `AtomicUsize`] .
19
19
//! Atomic types present operations that, when used correctly, synchronize
20
20
//! updates between threads.
21
21
//!
22
- //! Each method takes an `Ordering` which represents the strength of
22
+ //! [`AtomicBool`]: struct.AtomicBool.html
23
+ //! [`AtomicIsize`]: struct.AtomicIsize.html
24
+ //! [`AtomicUsize`]: struct.AtomicUsize.html
25
+ //!
26
+ //! Each method takes an [`Ordering`] which represents the strength of
23
27
//! the memory barrier for that operation. These orderings are the
24
28
//! same as [LLVM atomic orderings][1]. For more information see the [nomicon][2].
25
29
//!
30
+ //! [`Ordering`]: enum.Ordering.html
31
+ //!
26
32
//! [1]: http://llvm.org/docs/LangRef.html#memory-model-for-concurrent-operations
27
33
//! [2]: ../../../nomicon/atomics.html
28
34
//!
29
- //! Atomic variables are safe to share between threads (they implement `Sync`)
35
+ //! Atomic variables are safe to share between threads (they implement [ `Sync`] )
30
36
//! but they do not themselves provide the mechanism for sharing and follow the
31
37
//! [threading model](../../../std/thread/index.html#the-threading-model) of rust.
32
- //! The most common way to share an atomic variable is to put it into an `Arc` (an
38
+ //! The most common way to share an atomic variable is to put it into an [ `Arc`][arc] (an
33
39
//! atomically-reference-counted shared pointer).
34
40
//!
41
+ //! [`Sync`]: ../../marker/trait.Sync.html
42
+ //! [arc]: ../../../std/sync/struct.Arc.html
43
+ //!
35
44
//! Most atomic types may be stored in static variables, initialized using
36
- //! the provided static initializers like `ATOMIC_BOOL_INIT`. Atomic statics
45
+ //! the provided static initializers like [ `ATOMIC_BOOL_INIT`] . Atomic statics
37
46
//! are often used for lazy global initialization.
38
47
//!
48
+ //! [`ATOMIC_BOOL_INIT`]: constant.ATOMIC_BOOL_INIT.html
39
49
//!
40
50
//! # Examples
41
51
//!
@@ -148,22 +158,32 @@ unsafe impl<T> Sync for AtomicPtr<T> {}
148
158
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
149
159
#[ derive( Copy , Clone , Debug ) ]
150
160
pub enum Ordering {
151
- /// No ordering constraints, only atomic operations. Corresponds to LLVM's
152
- /// `Monotonic` ordering.
161
+ /// No ordering constraints, only atomic operations.
162
+ ///
163
+ /// Corresponds to LLVM's [`Monotonic`] ordering.
164
+ ///
165
+ /// [`Monotonic`]: http://llvm.org/docs/Atomics.html#monotonic
153
166
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
154
167
Relaxed ,
155
168
/// When coupled with a store, all previous writes become visible
156
- /// to the other threads that perform a load with `Acquire` ordering
169
+ /// to the other threads that perform a load with [ `Acquire`] ordering
157
170
/// on the same value.
171
+ ///
172
+ /// [`Acquire`]: http://llvm.org/docs/Atomics.html#acquire
158
173
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
159
174
Release ,
160
175
/// When coupled with a load, all subsequent loads will see data
161
- /// written before a store with `Release` ordering on the same value
176
+ /// written before a store with [ `Release`] ordering on the same value
162
177
/// in other threads.
178
+ ///
179
+ /// [`Release`]: http://llvm.org/docs/Atomics.html#release
163
180
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
164
181
Acquire ,
165
- /// When coupled with a load, uses `Acquire` ordering, and with a store
166
- /// `Release` ordering.
182
+ /// When coupled with a load, uses [`Acquire`] ordering, and with a store
183
+ /// [`Release`] ordering.
184
+ ///
185
+ /// [`Acquire`]: http://llvm.org/docs/Atomics.html#acquire
186
+ /// [`Release`]: http://llvm.org/docs/Atomics.html#release
167
187
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
168
188
AcqRel ,
169
189
/// Like `AcqRel` with the additional guarantee that all threads see all
@@ -176,7 +196,9 @@ pub enum Ordering {
176
196
__Nonexhaustive,
177
197
}
178
198
179
- /// An `AtomicBool` initialized to `false`.
199
+ /// An [`AtomicBool`] initialized to `false`.
200
+ ///
201
+ /// [`AtomicBool`]: struct.AtomicBool.html
180
202
#[ cfg( target_has_atomic = "8" ) ]
181
203
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
182
204
pub const ATOMIC_BOOL_INIT : AtomicBool = AtomicBool :: new ( false ) ;
@@ -250,7 +272,7 @@ impl AtomicBool {
250
272
///
251
273
/// [`Ordering`]: enum.Ordering.html
252
274
/// [`Release`]: enum.Ordering.html#variant.Release
253
- /// [`AcqRel`]: enum.Ordering.html#variant.Release
275
+ /// [`AcqRel`]: enum.Ordering.html#variant.AcqRel
254
276
///
255
277
/// # Examples
256
278
///
@@ -287,7 +309,10 @@ impl AtomicBool {
287
309
///
288
310
/// # Panics
289
311
///
290
- /// Panics if `order` is `Acquire` or `AcqRel`.
312
+ /// Panics if `order` is [`Acquire`] or [`AcqRel`].
313
+ ///
314
+ /// [`Acquire`]: enum.Ordering.html#variant.Acquire
315
+ /// [`AcqRel`]: enum.Ordering.html#variant.AcqRel
291
316
#[ inline]
292
317
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
293
318
pub fn store ( & self , val : bool , order : Ordering ) {
@@ -404,7 +429,7 @@ impl AtomicBool {
404
429
405
430
/// Stores a value into the `bool` if the current value is the same as the `current` value.
406
431
///
407
- /// Unlike `compare_exchange`, this function is allowed to spuriously fail even when the
432
+ /// Unlike [ `compare_exchange`] , this function is allowed to spuriously fail even when the
408
433
/// comparison succeeds, which can result in more efficient code on some platforms. The
409
434
/// return value is a result indicating whether the new value was written and containing the
410
435
/// previous value.
@@ -415,6 +440,7 @@ impl AtomicBool {
415
440
/// failure ordering can't be [`Release`] or [`AcqRel`] and must be equivalent or
416
441
/// weaker than the success ordering.
417
442
///
443
+ /// [`compare_exchange`]: #method.compare_exchange
418
444
/// [`Ordering`]: enum.Ordering.html
419
445
/// [`Release`]: enum.Ordering.html#variant.Release
420
446
/// [`AcqRel`]: enum.Ordering.html#variant.Release
@@ -694,7 +720,10 @@ impl<T> AtomicPtr<T> {
694
720
///
695
721
/// # Panics
696
722
///
697
- /// Panics if `order` is `Acquire` or `AcqRel`.
723
+ /// Panics if `order` is [`Acquire`] or [`AcqRel`].
724
+ ///
725
+ /// [`Acquire`]: enum.Ordering.html#variant.Acquire
726
+ /// [`AcqRel`]: enum.Ordering.html#variant.AcqRel
698
727
#[ inline]
699
728
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
700
729
pub fn store ( & self , ptr : * mut T , order : Ordering ) {
@@ -1008,7 +1037,10 @@ macro_rules! atomic_int {
1008
1037
///
1009
1038
/// # Panics
1010
1039
///
1011
- /// Panics if `order` is `Acquire` or `AcqRel`.
1040
+ /// Panics if `order` is [`Acquire`] or [`AcqRel`].
1041
+ ///
1042
+ /// [`Acquire`]: enum.Ordering.html#variant.Acquire
1043
+ /// [`AcqRel`]: enum.Ordering.html#variant.AcqRel
1012
1044
#[ inline]
1013
1045
#[ $stable]
1014
1046
pub fn store( & self , val: $int_type, order: Ordering ) {
0 commit comments