Re: [Boost-users] [general question] on threading and double checkedlocking pattern
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Ovanes Markarian
I might be wrong here, but I would like to hear some thoughts of C++ professionals.
I read in lots of sources about DCLP and how it is broken in conjunction with Singleton pattern and my question is of a very simple nature. Is it possible to solve this problem by introducing function calls via function pointers? Or is there still a way, that these calls might be inlined and if yes then how could this look like? This example is not about freeing the singleton, it is just about creating it.
Hi, Perhaps the path-of-least-debugging is to use boost::once? Sohail
On 1/22/07, Sohail Somani
Hi,
Perhaps the path-of-least-debugging is to use boost::once?
It definitely is. But if you could find a way to make it better, even with complicated and platform-dependent code, and then wrap it up into something usable, have it tested and peer-reviewed, and placed somewhere we could all use it, it would still be useful. Note that in the sentences above, I intentionally avoided mentioning anything about the particular problem, as it is a general truth - library code is allowed (at least somewhat) to be more complicated, if you assume it is going to be more used and more reviewed and more tested. Sohail P.S. In this particular case, I don't think you can get better than: - a read barrier and if-branch in the already-initted case - that + a write barrier in the init case - all wrapped into a single int. which is slightly, but not much better than a mutex. It is also slightly better than most implementations of boost::once/pthread_once, and much better than some, depending on platform. Tony
participants (2)
-
Gottlob Frege
-
Sohail Somani