|
Boost : |
From: Peter Simons (simons_at_[hidden])
Date: 2005-07-18 10:55:08
Jason Hise writes:
> singleton_ptr < Type > ptr;
> ptr.create ( /*ctor params here*/ );
> ptr.create ( /*ctor params here*/ );
What happens when two threads call create() at the same time?
> I will have to look up call_once before I will be able to
> compare it with my approach.
My guess is that you will need call_once() as part of your
implementation for it to be thread-safe (because of the
race-condition mentioned above).
> Others have expressed (perhaps not publicly) that their
> preferred method would be that secondary destructions are
> simply no-ops, rather than being errors or asserting at all.
> Such conflicting interests make it seem like a policy is
> indeed necessary.
Well, having a policy mechanism won't hurt. I'm all for it. ;-)
Peter
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk