Boost logo

Boost :

Subject: Re: [boost] Is there interest in an alternative to the Singleton anti-pattern?
From: Antony Polukhin (antoshkka_at_[hidden])
Date: 2011-06-26 05:27:59

I would like to see the updated source code. Even if boost vault is
deprecated and moved to github, it is still a good place to post

Two more remarks:
1) it would be great to use auto_ptr for instance_ptr_type. It will
make sure that the resource is deleted and the constructor called.

2011/6/25 Ben Robinson <icaretaker_at_[hidden]>:
> Singularity, I feel I still must make "instance_ptr" volatile for thread
> safety.  If I do not, the compiler can store the pointer in a register, and
> other threads of execution will not see changes to its value.  The linked
> article seems mostly concerned with fencing access to the variable, which I
> am achieving by using a mutex object.  I only need volatile to
> prevent effectively reading a "cached" value for the pointer.  I found the
> following article by Andrei Alexandrescu especially interesting:

It is not thread safe. Consider the article by Scott
Meyers and Andrei Alexandrescu. In the article by Andrei Alexandrescu
at there is no construction of object
in LockingPtr, and that makes a big difference!

Best regards,
Antony Polukhin

Boost list run by bdawes at, gregod at, cpdaniel at, john at