about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2025-03-04 15:14:59 +0100
committerRalf Jung <post@ralfj.de>2025-03-04 15:14:59 +0100
commit1a5a4537437285bbd0f7f4cc9525b312a44789b2 (patch)
tree3674d280e1bda092936c0dc88ca3662a9e2f0872
parent81d8edc2000aa38b08ad09fce22d90f1990b6459 (diff)
downloadrust-1a5a4537437285bbd0f7f4cc9525b312a44789b2.tar.gz
rust-1a5a4537437285bbd0f7f4cc9525b312a44789b2.zip
atomic: clarify that failing conditional RMW operations are not 'writes'
-rw-r--r--library/core/src/sync/atomic.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/library/core/src/sync/atomic.rs b/library/core/src/sync/atomic.rs
index 73180bde54a..d55fa347cc5 100644
--- a/library/core/src/sync/atomic.rs
+++ b/library/core/src/sync/atomic.rs
@@ -44,8 +44,9 @@
 //! The most important aspect of this model is that *data races* are undefined behavior. A data race
 //! is defined as conflicting non-synchronized accesses where at least one of the accesses is
 //! non-atomic. Here, accesses are *conflicting* if they affect overlapping regions of memory and at
-//! least one of them is a write. They are *non-synchronized* if neither of them *happens-before*
-//! the other, according to the happens-before order of the memory model.
+//! least one of them is a write. (A `compare_exchange` or `compare_exchange_weak` that does not
+//! succeed is not considered a write.) They are *non-synchronized* if neither of them
+//! *happens-before* the other, according to the happens-before order of the memory model.
 //!
 //! The other possible cause of undefined behavior in the memory model are mixed-size accesses: Rust
 //! inherits the C++ limitation that non-synchronized conflicting atomic accesses may not partially