c++ - Is it safe to use memory_order_relaxed to load an atomic variable, when in the only thread that writes to that variable? -


i have thread writes atomic variable. (using memory_order_release). thread a

there many other threads read variable. (using memory_order_acquire). thread b.

is safe, when in thread a, read variable memory_order_relaxed ?

yes, it's safe in sense behave same non-atomic variable manipulated single thread.

for example, if write-release sequenced before relaxed read in program order, , there no other writes variable, relaxed read see value written write-release (n3337 §1.10.12-13).


Comments