From: Anthony Williams (anthony_w.geo_at_[hidden])
Date: 2006-11-03 02:59:01
Roland Schwarz <roland.schwarz_at_[hidden]> writes:
> I would be interested in why you think once is superior to statically
> initializeable mutex?
> My personal believe is, if we have a clean (static) mutex we should
> prefer it, because it is one concept less the programmer has to
> learn and remeber.
> "once" concept was and is just a work-around a deficiency.
"Once" is more low-level. It can be used to initialize a mutex, *or any other
type of object*. Yes, if you have a static mutex, you can lock the mutex
around the initialization of another object, but that's unnecessarily complex:
static mutex m;
static some_class x;
// access x
You can't use a scoped_lock for this unless it has an unlock() member (which
IMO defeats the point of it being scoped), since otherwise you end up
serializing the "access x" part too.
-- Anthony Williams Software Developer Just Software Solutions Ltd http://www.justsoftwaresolutions.co.uk
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk