I have the following simple code:
size_t tail = _tail.load(std::memory_order_acquire);
size_t head = _head.load(std::memory_order_relaxed);
From what I understand, the acquire barrier acts as LoadLoad and LoadStore barrier, meaning that any loads after the barrier can’t be older than loads before the barrier, and loads before the barrier must also be younger than stores after the barrier. But how does this influence the loading of _head
now, since _head
doesn’t imply any memory ordering?
Let’s say another thread writes first to tail
then to head
using a StoreStore fence to make sure once head
is visible, tail
is visible as well in global memory. Could then (in the above snippet), _head
after loading still contain the previous value while _tail
would already contain the current value? Or how does the acquire barrier influence the relaxed ordering imposed later?