Boost logo

Boost :

From: Jason Hise (chaos_at_[hidden])
Date: 2005-01-12 13:27:04


Alexander Terekhov wrote:

>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. ;-) )
>
Please elaborate. I have very little threading background. What
exactly is a synchronized static local? Is this a class or object level
mutex, or something entirely different? The "some compilers" part
worries me a bit, as I would like this library to be portable. When you
refer to atomic<>, I presume you are referring to operations that are
indivisible at the processor level. Are there such operations that can
be assumed to be atomic on every processor, or would I be using a large
boost library that defines common atomic operations based on the
compiler, processor, and operating system? Thanks in advance.

-Jason


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk