From dc6a9421941d6b80f07b6884ce1c5cfdaaecaf44 Mon Sep 17 00:00:00 2001 From: SabrinaJewson Date: Sun, 28 Aug 2022 21:04:12 +0100 Subject: [PATCH] Explain the C++20 release sequence changes --- src/atomics/acquire-release.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/atomics/acquire-release.md b/src/atomics/acquire-release.md index 1ee7a4a..c2cb992 100644 --- a/src/atomics/acquire-release.md +++ b/src/atomics/acquire-release.md @@ -213,7 +213,13 @@ the `load` and everything sequenced after it. There is one more rule required for these to be useful, and that is _release sequences_: after a release store is performed on an atomic, happens-before arrows will connect together each subsequent value of the atomic as long as the -new value is caused by an RMW and not just a plain store. +new value is caused by an RMW and not just a plain store (this means any +subsequent normal store, no matter the ordering, will end the sequence). + +> In the C++11 memory model, any subsequent store by the same thread that +> performed the original `Release` store would also contribute to the release +> sequence. However, this was removed in C++20 for simplicity and better +> optimizations and so **must not** be relied upon. With those rules in mind, converting Thread 1’s second store to use a `Release` ordering as well as converting Thread 2’s CAS to use an `Acquire` ordering