std::atomic<bool> ready{false};
std::atomic<int> data{0};
void producer() {
data.store(42, std::memory_order_relaxed);
ready.store(true, std::memory_order_release);
}
Demystifying Memory Ordering in C++
Understanding acquire-release semantics and how to correctly implement lock-free data structures without relying on sequential consistency.