Boost logo

Boost :

From: Tobias Schwinger (tschwinger_at_[hidden])
Date: 2008-01-18 15:46:02

Peter Dimov wrote:
> Tobias Schwinger:
>> Peter Dimov wrote:
>>> What is the reason to prefer the current instance/lease formulation
>>> instead
>>> of
>>> typedef ... instance_type;
>>> instance_type instance(); // automatically serves as a lease
>>> ?
>> As we can't expose the instance when automatic locking is done, it is
>> supposed to provide a means to not have to access the instance directly.
> I'm not sure what this reformulation cannot do that the original can. An
> ordinary singleton can define instance_type as T*. A synchronized singleton
> can define instance_type as the moral equivalent of shared_ptr<T> (with a
> hidden unlocking deleter). What am I missing?

It was one goal to enforce client code not to make any assumptions about
the type of the pointer.
The reason was easy migration from an unsynchronized to a synchronized
scenario by enforcing threading-agnostic client code. Further, I found


syntacticly nicer than






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