Re: [boost] Is there interest in an alternative to the Singleton anti-pattern?

On 24 June 2011 02:06, Ben Robinson <icaretaker@gmail.com> wrote:
If you choose the default policy of single_threaded, there is no thread safety, but there is also no overhead in using a mutex and using a volatile pointer.
Volatile in C++ doesn't really help with threading... Check out < http://software.intel.com/en-us/blogs/2007/11/30/volatile -almost-useless-for-multi-threaded-programming/> for one of many articles on the subject. -- Nevin ":-)" Liber <mailto:nevin@eviloverlord.com> (847) 691-1404
Nevin, I greatly appreciate the input you have provided. I retract my original response, as I now better understand why volatile does not add any value to Singularity. Singularity is already acquiring a mutex object, before accessing the shared instance pointer, and that mutex acquisition is already providing memory fencing. I have simplified the implementation of Singularity and the latest version is available at: https://github.com/icaretaker/Singularity. Any additional input would be appreciated. Thank you, Ben Robinson, Ph.D.
participants (1)
-
Ben Robinson