Quantcast
Channel: Does memory_order_seq_cst store guarantee that memory_order_relaxed load will read written value? - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Does memory_order_seq_cst store guarantee that memory_order_relaxed load will read written value?

$
0
0

Is in the following code x_value guaranteed to be 42?

std::atomic<int> x;Thread A:  x.store(42, std::memory_order_seq_cst);  wakeThreadB();Thread B:  int x_value = x.load(std::memory_order_relaxed);  assert(x_value == 42);

I have tried to test it, and it seemed that thread B always reads correct value. But I'm not sure if it is guaranteed.


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images