On Feb 8, 1:01 pm, "Shawn McGrath" <shawn.mcgr...@gmail.comwrote:
Hey, I can't get DeletableSingleton to actually delete the singleton.
The code is:
typedef Loki::SingletonHolder<GenClass Loki::CreateUsingNew,
Loki::DeletableSingletonGen;
...
Gen::Instance();
...
Loki::DeletableSingleton<Gen>::GracefulDelete();
The destructor for GenClass never gets called until termination (ie:
via atexit()).
Does anyone have any experience with Loki's DeletableSingleton ?
Thanks
- Shawn.
There seems to be some bug here or in the way you are calling it.
The type (looking at the code in the Loki library) for which your
Destuction policy gets instantiated is the following...
typedef typename ThreadingModel<T*,MutexPolicy>::VolatileType
PtrInstanceType;
which I guess evaluates to T*...
while in your code, you call GraceFullDelete with T...2 different
instantations,...
and since GraceFullDelete checks for a few internal variables...it
returns without deleting..
and hence your stuff gets deleted only at atexit time.
Look at the Loki code and the examples.