std::atomic Memory Order Relaxed
Which guarantee does std::memory_order_relaxed provide?
std::atomic<int> x{0}, y{0};
// Thread 1
x.store(1, std::memory_order_relaxed);
y.store(1, std::memory_order_relaxed);
// Thread 2
int r1 = y.load(std::memory_order_relaxed);
int r2 = x.load(std::memory_order_relaxed);
Sign in to answer questions and track your progress
Sign In