
12 Jan
2005
12 Jan
'05
12:35 p.m.
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. ;-) ) regards, alexander. *) E.g. see http://www.codesourcery.com/cxx-abi/abi.html#once-ctor