
18 Jul
2005
18 Jul
'05
3:55 p.m.
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