From: Jason Hise (chaos_at_[hidden])
Date: 2005-01-10 22:37:51
Dave Handley wrote:
> Great work - I've been away from the list for a couple of days so
> sorry I didn't get back sooner, but I think you have definitely gone
> the right way with what you've done up to now.
> My recommendations for things to look at include:
> 1) Allocate using malloc as another creation policy
> 2) Longevity lifetimes
I'm actually working on the longevity policy now. I'm trying to do it
without using atexit, and instead using a hidden internal singleton that
manages the lifetimes of the others. It should be interesting.
> 3) Possibly include the ability to turn off phoenix singletons in
> the dependency lifetime policy.
This leads to an interesting question: what should happen if a class
tries to get access to a destroyed singleton? I would personally think
that it would always be desirable to have it come back, but then this is
just my opinion and probably falls into the same category as me
preferring dependencies to longevities. Which leads me to wonder if
OnDeadReference should be an additional policy of the lifetime policy
> 4) Threading.
I'm going to need help with this one. My current thought is to provide
a lock policy. The lock would be required to provide locking upon
creation and unlocking upon destruction, and then all the other policies
of the singleton would inherit this policy and could simply insert lock
objects wherever they are needed. The default single threaded lock
would just be an empty class. Unfortunately I have no experience with
how threading actually works, and I am worried that the two threads
would just end up creating two different locks and neither would block
the other. If I am not on the right track, please point me in the right
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk