Ahhh, the following interesting discussion might be of interest wrt the
standalone fences:
https://groups.google.com/d/topic/lock-free/A1nzcMBGRzU/discussion
(read all...)
Another reason why I like standalone fences is that we can place them in
the _exact_ places they need to be. The other style of fences are
directly integrated into the std::atomic operations themselves. However,
they can be limited wrt flexibility. Take the following code into
account: It flushes all of the nodes from an atomic stack in a single
atomic operation:
_____________________________
// try to flush all of our nodes
node* flush()
{
node* n = m_head.exchange(nullptr, mb_relaxed);
if (n)
{
mb_fence(mb_acquire);
}
return n;
}
_____________________________
Notice how this specialized 100% standard membar setup is _impossible_
to accomplish with the integrated membars? Standalone fences are what I
am basically used to working with way back on the SPARC.