Skip to content

Commit c5082fe

Browse files
authored
Rollup merge of #40871 - projektir:atomic_links, r=steveklabnik
Adding links for Atomics docs #29377 r? @steveklabnik This should be good for `std::sync::atomic`. The other pages still need more (examples, etc.).
2 parents 6edab01 + 4ea03c8 commit c5082fe

File tree

1 file changed

+49
-17
lines changed

1 file changed

+49
-17
lines changed

src/libcore/sync/atomic.rs

+49-17
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,37 @@
1515
//! types.
1616
//!
1717
//! 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`].
1919
//! Atomic types present operations that, when used correctly, synchronize
2020
//! updates between threads.
2121
//!
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
2327
//! the memory barrier for that operation. These orderings are the
2428
//! same as [LLVM atomic orderings][1]. For more information see the [nomicon][2].
2529
//!
30+
//! [`Ordering`]: enum.Ordering.html
31+
//!
2632
//! [1]: http://llvm.org/docs/LangRef.html#memory-model-for-concurrent-operations
2733
//! [2]: ../../../nomicon/atomics.html
2834
//!
29-
//! Atomic variables are safe to share between threads (they implement `Sync`)
35+
//! Atomic variables are safe to share between threads (they implement [`Sync`])
3036
//! but they do not themselves provide the mechanism for sharing and follow the
3137
//! [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
3339
//! atomically-reference-counted shared pointer).
3440
//!
41+
//! [`Sync`]: ../../marker/trait.Sync.html
42+
//! [arc]: ../../../std/sync/struct.Arc.html
43+
//!
3544
//! 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
3746
//! are often used for lazy global initialization.
3847
//!
48+
//! [`ATOMIC_BOOL_INIT`]: constant.ATOMIC_BOOL_INIT.html
3949
//!
4050
//! # Examples
4151
//!
@@ -148,22 +158,32 @@ unsafe impl<T> Sync for AtomicPtr<T> {}
148158
#[stable(feature = "rust1", since = "1.0.0")]
149159
#[derive(Copy, Clone, Debug)]
150160
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
153166
#[stable(feature = "rust1", since = "1.0.0")]
154167
Relaxed,
155168
/// 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
157170
/// on the same value.
171+
///
172+
/// [`Acquire`]: http://llvm.org/docs/Atomics.html#acquire
158173
#[stable(feature = "rust1", since = "1.0.0")]
159174
Release,
160175
/// 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
162177
/// in other threads.
178+
///
179+
/// [`Release`]: http://llvm.org/docs/Atomics.html#release
163180
#[stable(feature = "rust1", since = "1.0.0")]
164181
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
167187
#[stable(feature = "rust1", since = "1.0.0")]
168188
AcqRel,
169189
/// Like `AcqRel` with the additional guarantee that all threads see all
@@ -176,7 +196,9 @@ pub enum Ordering {
176196
__Nonexhaustive,
177197
}
178198

179-
/// An `AtomicBool` initialized to `false`.
199+
/// An [`AtomicBool`] initialized to `false`.
200+
///
201+
/// [`AtomicBool`]: struct.AtomicBool.html
180202
#[cfg(target_has_atomic = "8")]
181203
#[stable(feature = "rust1", since = "1.0.0")]
182204
pub const ATOMIC_BOOL_INIT: AtomicBool = AtomicBool::new(false);
@@ -250,7 +272,7 @@ impl AtomicBool {
250272
///
251273
/// [`Ordering`]: enum.Ordering.html
252274
/// [`Release`]: enum.Ordering.html#variant.Release
253-
/// [`AcqRel`]: enum.Ordering.html#variant.Release
275+
/// [`AcqRel`]: enum.Ordering.html#variant.AcqRel
254276
///
255277
/// # Examples
256278
///
@@ -287,7 +309,10 @@ impl AtomicBool {
287309
///
288310
/// # Panics
289311
///
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
291316
#[inline]
292317
#[stable(feature = "rust1", since = "1.0.0")]
293318
pub fn store(&self, val: bool, order: Ordering) {
@@ -404,7 +429,7 @@ impl AtomicBool {
404429

405430
/// Stores a value into the `bool` if the current value is the same as the `current` value.
406431
///
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
408433
/// comparison succeeds, which can result in more efficient code on some platforms. The
409434
/// return value is a result indicating whether the new value was written and containing the
410435
/// previous value.
@@ -415,6 +440,7 @@ impl AtomicBool {
415440
/// failure ordering can't be [`Release`] or [`AcqRel`] and must be equivalent or
416441
/// weaker than the success ordering.
417442
///
443+
/// [`compare_exchange`]: #method.compare_exchange
418444
/// [`Ordering`]: enum.Ordering.html
419445
/// [`Release`]: enum.Ordering.html#variant.Release
420446
/// [`AcqRel`]: enum.Ordering.html#variant.Release
@@ -694,7 +720,10 @@ impl<T> AtomicPtr<T> {
694720
///
695721
/// # Panics
696722
///
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
698727
#[inline]
699728
#[stable(feature = "rust1", since = "1.0.0")]
700729
pub fn store(&self, ptr: *mut T, order: Ordering) {
@@ -1008,7 +1037,10 @@ macro_rules! atomic_int {
10081037
///
10091038
/// # Panics
10101039
///
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
10121044
#[inline]
10131045
#[$stable]
10141046
pub fn store(&self, val: $int_type, order: Ordering) {

0 commit comments

Comments
 (0)