Skip to content

Commit 3eef20f

Browse files
committed
Improve documentation on success and failure arguments
1 parent 427996a commit 3eef20f

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.
@@ -1138,9 +1140,10 @@ impl<T> AtomicPtr<T> {
11381140
/// the previous value. On success this value is guaranteed to be equal to `current`.
11391141
///
11401142
/// `compare_exchange` takes two [`Ordering`] arguments to describe the memory
1141-
/// ordering of this operation. The first describes the required ordering if the
1142-
/// operation succeeds while the second describes the required ordering when the
1143-
/// operation fails. Using [`Acquire`] as success ordering makes the store part
1143+
/// ordering of this operation. `success` describes the required ordering for the
1144+
/// read-modify-write operation that takes place if the comparison with `current` succeeds.
1145+
/// `failure` describes the required ordering for the load operation that takes place when
1146+
/// the comparison fails. Using [`Acquire`] as success ordering makes the store part
11441147
/// of this operation [`Relaxed`], and using [`Release`] makes the successful load
11451148
/// [`Relaxed`]. The failure ordering can only be [`SeqCst`], [`Acquire`] or [`Relaxed`]
11461149
/// and must be equivalent to or weaker than the success ordering.
@@ -1201,9 +1204,10 @@ impl<T> AtomicPtr<T> {
12011204
/// previous value.
12021205
///
12031206
/// `compare_exchange_weak` takes two [`Ordering`] arguments to describe the memory
1204-
/// ordering of this operation. The first describes the required ordering if the
1205-
/// operation succeeds while the second describes the required ordering when the
1206-
/// operation fails. Using [`Acquire`] as success ordering makes the store part
1207+
/// ordering of this operation. `success` describes the required ordering for the
1208+
/// read-modify-write operation that takes place if the comparison with `current` succeeds.
1209+
/// `failure` describes the required ordering for the load operation that takes place when
1210+
/// the comparison fails. Using [`Acquire`] as success ordering makes the store part
12071211
/// of this operation [`Relaxed`], and using [`Release`] makes the successful load
12081212
/// [`Relaxed`]. The failure ordering can only be [`SeqCst`], [`Acquire`] or [`Relaxed`]
12091213
/// and must be equivalent to or weaker than the success ordering.
@@ -1708,9 +1712,10 @@ containing the previous value. On success this value is guaranteed to be equal t
17081712
`current`.
17091713
17101714
`compare_exchange` takes two [`Ordering`] arguments to describe the memory
1711-
ordering of this operation. The first describes the required ordering if the
1712-
operation succeeds while the second describes the required ordering when the
1713-
operation fails. Using [`Acquire`] as success ordering makes the store part
1715+
ordering of this operation. `success` describes the required ordering for the
1716+
read-modify-write operation that takes place if the comparison with `current` succeeds.
1717+
`failure` describes the required ordering for the load operation that takes place when
1718+
the comparison fails. Using [`Acquire`] as success ordering makes the store part
17141719
of this operation [`Relaxed`], and using [`Release`] makes the successful load
17151720
[`Relaxed`]. The failure ordering can only be [`SeqCst`], [`Acquire`] or [`Relaxed`]
17161721
and must be equivalent to or weaker than the success ordering.
@@ -1760,9 +1765,10 @@ platforms. The return value is a result indicating whether the new value was
17601765
written and containing the previous value.
17611766
17621767
`compare_exchange_weak` takes two [`Ordering`] arguments to describe the memory
1763-
ordering of this operation. The first describes the required ordering if the
1764-
operation succeeds while the second describes the required ordering when the
1765-
operation fails. Using [`Acquire`] as success ordering makes the store part
1768+
ordering of this operation. `success` describes the required ordering for the
1769+
read-modify-write operation that takes place if the comparison with `current` succeeds.
1770+
`failure` describes the required ordering for the load operation that takes place when
1771+
the comparison fails. Using [`Acquire`] as success ordering makes the store part
17661772
of this operation [`Relaxed`], and using [`Release`] makes the successful load
17671773
[`Relaxed`]. The failure ordering can only be [`SeqCst`], [`Acquire`] or [`Relaxed`]
17681774
and must be equivalent to or weaker than the success ordering.

0 commit comments

Comments
 (0)