[cpp-threads] atomic operations package
Peter Dimov
pdimov at mmltd.net
Thu Aug 25 15:23:57 BST 2005
Boehm, Hans wrote:
> It still seems to me that if we use templates only at the top level,
> with some predefined instantiations for "template haters" and C
> programmers, and "run-time" parameterization for the sync arguments,
> we should be OK. And since these functions should normally be
> inlined, there shouldn't be any run-time overhead. (Unlike
> the template version, we can't guarantee that, but that's minor.)
The "runtime" formulation isn't actually runtime even in its library
incarnation, it's still a template, because the types of the various msync_*
values can differ. So instead of
template<class T> class atomic
{
template<class Msync> T load();
};
you have
template<class T, class Msync> T atomic_load( T * location, Msync msync );
which does have the same two template parameters as the above, it's just the
syntax that you expose to the outside (possibly-template-unfriendly) world
that is different.
Of course if atomic_load is a compiler intrinsic, msync_* can just be
integral constants, since the dispatch can still happen at compile time.
More information about the cpp-threads
mailing list