Boost logo

Boost :

Subject: Re: [boost] Review Request: Singularity
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2011-08-24 12:24:08


On 24/08/2011 15:29, Alexey Tkachenko wrote:
>
> On 24-Aug-2011, at 9:18 PM, Mathias Gaunard wrote:
>
>> On 24/08/2011 04:28, Ben Robinson wrote:
>>> Mathias,
>>>
>>> I think this discussion is getting a little off track. There is a lot
>>> of literature on creating a thread-safe Singleton that manages the lifetime
>>> of your object according to your needs. However, there is no silver bullet
>>> for the pattern. Different variants make different tradeoffs depending on
>>> the user's needs. The three issues that are inherent to Singleton are:
>>>
>>> 1) You have little control over when the Singleton is destroyed. Should you
>>> have multiple Singleton which depend on each-other, very often you need a
>>> very specific teardown order.
>>
>> It should be the inverse order of the construction order.
>
> Consider dependency between singletons

Your point being?

Construct your singletons in the order required by your dependency, then
let destruction happen in the inverse order.

function-level statics are constructed *on the first call of the
function*, not in an unspecified order like class-level statics or
global variables.


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