Boost logo

Boost :

From: Jason Hise (chaos_at_[hidden])
Date: 2005-01-09 15:34:48


Thomas Beckmann wrote:

> Wouldn't it be easier to change AddDependency to something like the
> following:
>
> static void AddDependency ( )
> {
> static bool first = true;
>
> if ( first ) {
> s_inst = static_cast < T * > ( A :: Create ( ) );
> dependents = 0;
> first = false;
> }
> ++dependents;
> }

The problem is that this makes recreating the singleton impossible...
you lose the phoenix effect. Also, creating the singleton might
inadvertently result in creating something else that creates something
else that has a singleton dependency. If such a thing happens,
dependents should be in a correct state ( aka incremented ) before
create is called.

-Jason


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk