[cpp-threads] modes, interlude
Peter Dimov
pdimov at mmltd.net
Tue May 10 01:17:51 BST 2005
Doug Lea wrote:
> If we are going to do this, is there any reason not go all the way and
> have four flavors of explicit barrier functions in the atomic classes
We will.
template<class M> void barrier( M msync );
> and not bother adding modes to load, store etc?
A library can't fold the explicit barrier() calls into the preceding or
subsequent atomic operation, so providing only barrier() may be inefficient
for the first ten years or so. :-)
On platforms where a bidirectional barrier is the natural primitive, the
modes can easily be implemented in terms of barriers:
template<class M, class T> T atomic_load( M msync, T * addr )
{
barrier( (msync & msync_rel) | msync_hlb );
T r = _load_none( addr );
barrier( (msync & msync_acq) | msync_slb );
return r;
}
("constraint algebra" at work.)
More information about the cpp-threads
mailing list