Boost logo

Boost :

From: Anthony Williams (anthony_w.geo_at_[hidden])
Date: 2005-09-07 16:59:42

Alexander Terekhov <terekhov_at_[hidden]> writes:

> Anthony Williams wrote:
> [...]
>> Destruction of once_flags with static storage duration.
>> If we store the return value along with the once_flag, then we really ought
>> to destroy it properly, when the once_flag is destroyed. If a once_flag has
>> static storage duration, and has a non-trivial destructor that does
>> cleanup, then we have a classic singleton cleanup problem, as John Maddock
>> pointed out --- the order of static destruction can now be important.
> You mean an extra non-POD version? That's not your problem... as long
> as you provide a POD version + call_once_reset/destroy().

So, you're suggesting that we store the result with the once_flag, and then
leave it up to users to schedule a call to call_once_reset, to ensure the
result gets cleared up?


I'd still like to know how the user can safely schedule the call to
call_once_reset, so it doesn't cause problems. I suppose there's an element to
which it doesn't really matter; the result will just be reinitialized if
there's a subsequent call_once.

I don't like leaving things as "not my problem", unless I can see that there
is a safe solution.


Anthony Williams
Software Developer
Just Software Solutions Ltd

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