Skip to content

Commit cc63bd4

Browse files
committed
atomic::Ordering: Get rid of misleading parts of intro
Remove the parts of atomic::Ordering's intro that wrongly claimed that SeqCst prevents all reorderings around it. Closes #55196
1 parent f6e9485 commit cc63bd4

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/libcore/sync/atomic.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -173,18 +173,20 @@ unsafe impl<T> Sync for AtomicPtr<T> {}
173173

174174
/// Atomic memory orderings
175175
///
176-
/// Memory orderings limit the ways that both the compiler and CPU may reorder
177-
/// instructions around atomic operations. At its most restrictive,
178-
/// "sequentially consistent" atomics allow neither reads nor writes
179-
/// to be moved either before or after the atomic operation; on the other end
180-
/// "relaxed" atomics allow all reorderings.
176+
/// Memory orderings specify the way atomic operations synchronize memory.
177+
/// In its weakest [`Relaxed`][Ordering::Relaxed], only the memory directly touched by the
178+
/// operation is synchronized. On the other hand, a store-load pair of [`SeqCst`][Ordering::SeqCst]
179+
/// operations synchronize other memory while additionally preserving a total order of such
180+
/// operations across all threads.
181181
///
182182
/// Rust's memory orderings are [the same as
183183
/// LLVM's](https://llvm.org/docs/LangRef.html#memory-model-for-concurrent-operations).
184184
///
185185
/// For more information see the [nomicon].
186186
///
187187
/// [nomicon]: ../../../nomicon/atomics.html
188+
/// [Ordering::Relaxed]: #variant.Relaxed
189+
/// [Ordering::SeqCst]: #variant.SeqCst
188190
#[stable(feature = "rust1", since = "1.0.0")]
189191
#[derive(Copy, Clone, Debug)]
190192
#[non_exhaustive]
@@ -234,8 +236,8 @@ pub enum Ordering {
234236
/// For loads it uses [`Acquire`] ordering. For stores it uses the [`Release`] ordering.
235237
///
236238
/// Notice that in the case of `compare_and_swap`, it is possible that the operation ends up
237-
/// not performing any store and hence it has just `Acquire` ordering. However,
238-
/// `AcqRel` will never perform [`Relaxed`] accesses.
239+
/// not performing any store and hence it has just [`Acquire`] ordering. However,
240+
/// [`AcqRel`][`AcquireRelease`] will never perform [`Relaxed`] accesses.
239241
///
240242
/// This ordering is only applicable for operations that combine both loads and stores.
241243
///

0 commit comments

Comments
 (0)