
-----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org]On Behalf Of Eric Niebler Sent: Wednesday, June 09, 2004 11:15 AM To: boost@lists.boost.org Subject: [boost] Re: Thread lib (good reason for static)
[snip]
That's what the double-checked locking pattern for
singletons is for.
Regards,
Matt Hurd.
No, the double-checked locking pattern is only good as the subject of talks describing why it's not good for anything.
Yeah! Of course I have to admit I'd never heard of DCLP before ;-) Read the notes quickly and they are very nicely presented. The actual bug that I created was related to the mutex controlling instantiation. Essentially if there is a multi-access issue around instantiation, how does adding a mutex make it better, i.e. how does the mutex get constructed (safely)? In the notes this is the following line on page 8. I'm assuming "args" is a constructed mutex; Lock L( args); // Acquire mutex or other lock While this is becoming something of a tangent maybe it qualifies as an example of why globals creating threads in ctors is a bear? Cheers, Scott