Boost logo

Boost :

From: Alexander Terekhov (terekhov_at_[hidden])
Date: 2005-01-12 07:35:29

Jason Hise wrote:
> header. The main thing that I would like to know is what this thread
> safety *interface* should look like, if it should provide any features
> other than locking, and/or how specifically it should be used within the
> singleton itself (aka what operations need to be locked).

Nothing at all if the singleton itself is immutable or "atomic<>"-ized
internally (lock-free). In this case, for thread-safe lazy init and
static storage duration, the best "interface" is a synchronized static
local. Some compilers* turn all static locals into synchronized static
locals. (In MT mode. Same policy thing as with boost::shared_ptr. ;-) )


*) E.g. see

Boost list run by bdawes at, gregod at, cpdaniel at, john at