
Roland Schwarz <roland.schwarz@chello.at> 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: void f() { static mutex m; m.lock(); static some_class x; m.unlock(); // 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 -- Anthony Williams Software Developer Just Software Solutions Ltd http://www.justsoftwaresolutions.co.uk