@@ -193,32 +193,67 @@ pub enum Ordering {
193
193
/// [`Monotonic`]: http://llvm.org/docs/Atomics.html#monotonic
194
194
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
195
195
Relaxed ,
196
- /// When coupled with a store, all previous writes become visible
197
- /// to the other threads that perform a load with [`Acquire`] ordering
198
- /// on the same value.
196
+ /// When coupled with a store, all previous operations become ordered
197
+ /// before any load of this value with [`Acquire`] (or stronger) ordering.
198
+ /// In particular, all previous writes become visible to all threads
199
+ /// that perform an [`Acquire`] (or stronger) load of this value.
199
200
///
201
+ /// Notice that using this ordering for an operation that combines loads
202
+ /// and stores leads to a [`Relaxed`] load operation!
203
+ ///
204
+ /// This ordering is only applicable for operations that can perform a store.
205
+ ///
206
+ /// Corresponds to LLVM's [`Release`] ordering.
207
+ ///
208
+ /// [`Release`]: http://llvm.org/docs/Atomics.html#release
200
209
/// [`Acquire`]: http://llvm.org/docs/Atomics.html#acquire
210
+ /// [`Relaxed`]: https://llvm.org/docs/Atomics.html#monotonic
201
211
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
202
212
Release ,
203
- /// When coupled with a load, all subsequent loads will see data
204
- /// written before a store with [`Release`] ordering on the same value
205
- /// in other threads.
213
+ /// When coupled with a load, if the loaded value was written by a store operation with
214
+ /// [`Release`] (or stronger) ordering, then all subsequent operations
215
+ /// become ordered after that store. In particular, all subsequent loads will see data
216
+ /// written before the store.
206
217
///
218
+ /// Notice that using this ordering for an operation that combines loads
219
+ /// and stores leads to a [`Relaxed`] store operation!
220
+ ///
221
+ /// This ordering is only applicable for operations that can perform a load.
222
+ ///
223
+ /// Corresponds to LLVM's [`Acquire`] ordering.
224
+ ///
225
+ /// [`Acquire`]: http://llvm.org/docs/Atomics.html#acquire
207
226
/// [`Release`]: http://llvm.org/docs/Atomics.html#release
227
+ /// [`Relaxed`]: https://llvm.org/docs/Atomics.html#monotonic
208
228
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
209
229
Acquire ,
210
- /// Has the effects of both [`Acquire`] and [`Release`] together.
230
+ /// Has the effects of both [`Acquire`] and [`Release`] together:
231
+ /// For loads it uses [`Acquire`] ordering. For stores it uses the [`Release`] ordering.
232
+ ///
233
+ /// Notice that in the case of `compare_and_swap`, it is possible that the operation ends up
234
+ /// not performing any store and hence it has just `Acquire` ordering. However,
235
+ /// `AcqRel` will never perform [`Relaxed`] accesses.
211
236
///
212
237
/// This ordering is only applicable for operations that combine both loads and stores.
213
238
///
214
- /// For loads it uses [`Acquire`] ordering. For stores it uses the [`Release `] ordering.
239
+ /// Corresponds to LLVM's [`AcquireRelease `] ordering.
215
240
///
241
+ /// [`AcquireRelease`]: http://llvm.org/docs/Atomics.html#acquirerelease
216
242
/// [`Acquire`]: http://llvm.org/docs/Atomics.html#acquire
217
243
/// [`Release`]: http://llvm.org/docs/Atomics.html#release
244
+ /// [`Relaxed`]: https://llvm.org/docs/Atomics.html#monotonic
218
245
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
219
246
AcqRel ,
220
- /// Like `AcqRel` with the additional guarantee that all threads see all
247
+ /// Like [`Acquire`]/[`Release`]/[`AcqRel`] (for load, store, and load-with-store
248
+ /// operations, respectively) with the additional guarantee that all threads see all
221
249
/// sequentially consistent operations in the same order.
250
+ ///
251
+ /// Corresponds to LLVM's [`SequentiallyConsistent`] ordering.
252
+ ///
253
+ /// [`SequentiallyConsistent`]: http://llvm.org/docs/Atomics.html#sequentiallyconsistent
254
+ /// [`Acquire`]: http://llvm.org/docs/Atomics.html#acquire
255
+ /// [`Release`]: http://llvm.org/docs/Atomics.html#release
256
+ /// [`AcqRel`]: https://llvm.org/docs/Atomics.html#acquirerelease
222
257
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
223
258
SeqCst ,
224
259
// Prevent exhaustive matching to allow for future extension
@@ -384,9 +419,11 @@ impl AtomicBool {
384
419
/// was updated.
385
420
///
386
421
/// `compare_and_swap` also takes an [`Ordering`] argument which describes the memory
387
- /// ordering of this operation.
422
+ /// ordering of this operation. Notice that even when using [`AcqRel`], the operation
423
+ /// might fail and hence just perform an `Acquire` load, but not have `Release` semantics.
388
424
///
389
425
/// [`Ordering`]: enum.Ordering.html
426
+ /// [`Ordering`]: enum.Ordering.html#variant.AcqRel
390
427
/// [`bool`]: ../../../std/primitive.bool.html
391
428
///
392
429
/// # Examples
@@ -421,7 +458,7 @@ impl AtomicBool {
421
458
/// ordering of this operation. The first describes the required ordering if the
422
459
/// operation succeeds while the second describes the required ordering when the
423
460
/// operation fails. The failure ordering can't be [`Release`] or [`AcqRel`] and must
424
- /// be equivalent or weaker than the success ordering.
461
+ /// be equivalent to or weaker than the success ordering.
425
462
///
426
463
/// [`bool`]: ../../../std/primitive.bool.html
427
464
/// [`Ordering`]: enum.Ordering.html
0 commit comments