So I had a singleton and it had a good use: it was a event notification window that classes could register interest in messages (WM_*) from. I used a Meyer''s singleton to ensure it was constructed when necessary.
And then the classes that registered for those were singletons, but I secretly knew they didn''t HAVE to be. So, I''m converting them to be static methods. I figured out I could make a static instantation of the class like so:
static TimerManager singleton
in the cpp file. However I still have problems with the destructor:
TimerManager::~TimerManager()
{
EventNotifier::Instance().Unregister(this, WM_TIMER);
}
Since order of destruction is undefined it is possible the EventNotifier instance would be gone before the TimerManager''s.
Is there any way to get around this? I looked at the GD article but am not quite sure how it applies to singletons that need defined order of destruction.
--God has paid us the intolerable compliment of loving us, in the deepest, most tragic, most inexorable sense.- C.S. Lewis