Skip to content

Commit 7a40b6d

Browse files
committed
Improve documentation on success and failure arguments
1 parent ed7b244 commit 7a40b6d

File tree

1 file changed

+24
-18
lines changed

1 file changed

+24
-18
lines changed

library/core/src/sync/atomic.rs

+24-18
Original file line numberDiff line numberDiff line change
@@ -514,9 +514,10 @@ impl AtomicBool {
514514
/// the previous value. On success this value is guaranteed to be equal to `current`.
515515
///
516516
/// `compare_exchange` takes two [`Ordering`] arguments to describe the memory
517-
/// ordering of this operation. The first describes the required ordering if the
518-
/// operation succeeds while the second describes the required ordering when the
519-
/// operation fails. Using [`Acquire`] as success ordering makes the store part
517+
/// ordering of this operation. `success` describes the required ordering for the
518+
/// read-modify-write operation that takes place if the comparison with `current` succeeds.
519+
/// `failure` describes the required ordering for the load operation that takes place when
520+
/// the comparison fails. Using [`Acquire`] as success ordering makes the store part
520521
/// of this operation [`Relaxed`], and using [`Release`] makes the successful load
521522
/// [`Relaxed`]. The failure ordering can only be [`SeqCst`], [`Acquire`] or [`Relaxed`]
522523
/// and must be equivalent to or weaker than the success ordering.
@@ -572,9 +573,10 @@ impl AtomicBool {
572573
/// previous value.
573574
///
574575
/// `compare_exchange_weak` takes two [`Ordering`] arguments to describe the memory
575-
/// ordering of this operation. The first describes the required ordering if the
576-
/// operation succeeds while the second describes the required ordering when the
577-
/// operation fails. Using [`Acquire`] as success ordering makes the store part
576+
/// ordering of this operation. `success` describes the required ordering for the
577+
/// read-modify-write operation that takes place if the comparison with `current` succeeds.
578+
/// `failure` describes the required ordering for the load operation that takes place when
579+
/// the comparison fails. Using [`Acquire`] as success ordering makes the store part
578580
/// of this operation [`Relaxed`], and using [`Release`] makes the successful load
579581
/// [`Relaxed`]. The failure ordering can only be [`SeqCst`], [`Acquire`] or [`Relaxed`]
580582
/// and must be equivalent to or weaker than the success ordering.
@@ -1116,9 +1118,10 @@ impl<T> AtomicPtr<T> {
11161118
/// the previous value. On success this value is guaranteed to be equal to `current`.
11171119
///
11181120
/// `compare_exchange` takes two [`Ordering`] arguments to describe the memory
1119-
/// ordering of this operation. The first describes the required ordering if the
1120-
/// operation succeeds while the second describes the required ordering when the
1121-
/// operation fails. Using [`Acquire`] as success ordering makes the store part
1121+
/// ordering of this operation. `success` describes the required ordering for the
1122+
/// read-modify-write operation that takes place if the comparison with `current` succeeds.
1123+
/// `failure` describes the required ordering for the load operation that takes place when
1124+
/// the comparison fails. Using [`Acquire`] as success ordering makes the store part
11221125
/// of this operation [`Relaxed`], and using [`Release`] makes the successful load
11231126
/// [`Relaxed`]. The failure ordering can only be [`SeqCst`], [`Acquire`] or [`Relaxed`]
11241127
/// and must be equivalent to or weaker than the success ordering.
@@ -1173,9 +1176,10 @@ impl<T> AtomicPtr<T> {
11731176
/// previous value.
11741177
///
11751178
/// `compare_exchange_weak` takes two [`Ordering`] arguments to describe the memory
1176-
/// ordering of this operation. The first describes the required ordering if the
1177-
/// operation succeeds while the second describes the required ordering when the
1178-
/// operation fails. Using [`Acquire`] as success ordering makes the store part
1179+
/// ordering of this operation. `success` describes the required ordering for the
1180+
/// read-modify-write operation that takes place if the comparison with `current` succeeds.
1181+
/// `failure` describes the required ordering for the load operation that takes place when
1182+
/// the comparison fails. Using [`Acquire`] as success ordering makes the store part
11791183
/// of this operation [`Relaxed`], and using [`Release`] makes the successful load
11801184
/// [`Relaxed`]. The failure ordering can only be [`SeqCst`], [`Acquire`] or [`Relaxed`]
11811185
/// and must be equivalent to or weaker than the success ordering.
@@ -1671,9 +1675,10 @@ containing the previous value. On success this value is guaranteed to be equal t
16711675
`current`.
16721676
16731677
`compare_exchange` takes two [`Ordering`] arguments to describe the memory
1674-
ordering of this operation. The first describes the required ordering if the
1675-
operation succeeds while the second describes the required ordering when the
1676-
operation fails. Using [`Acquire`] as success ordering makes the store part
1678+
ordering of this operation. `success` describes the required ordering for the
1679+
read-modify-write operation that takes place if the comparison with `current` succeeds.
1680+
`failure` describes the required ordering for the load operation that takes place when
1681+
the comparison fails. Using [`Acquire`] as success ordering makes the store part
16771682
of this operation [`Relaxed`], and using [`Release`] makes the successful load
16781683
[`Relaxed`]. The failure ordering can only be [`SeqCst`], [`Acquire`] or [`Relaxed`]
16791684
and must be equivalent to or weaker than the success ordering.
@@ -1723,9 +1728,10 @@ platforms. The return value is a result indicating whether the new value was
17231728
written and containing the previous value.
17241729
17251730
`compare_exchange_weak` takes two [`Ordering`] arguments to describe the memory
1726-
ordering of this operation. The first describes the required ordering if the
1727-
operation succeeds while the second describes the required ordering when the
1728-
operation fails. Using [`Acquire`] as success ordering makes the store part
1731+
ordering of this operation. `success` describes the required ordering for the
1732+
read-modify-write operation that takes place if the comparison with `current` succeeds.
1733+
`failure` describes the required ordering for the load operation that takes place when
1734+
the comparison fails. Using [`Acquire`] as success ordering makes the store part
17291735
of this operation [`Relaxed`], and using [`Release`] makes the successful load
17301736
[`Relaxed`]. The failure ordering can only be [`SeqCst`], [`Acquire`] or [`Relaxed`]
17311737
and must be equivalent to or weaker than the success ordering.

0 commit comments

Comments
 (0)