Loki DeletableSingleton

S

Shawn McGrath

Hey, I can't get DeletableSingleton to actually delete the singleton.

The code is:

typedef Loki::SingletonHolder<GenClass Loki::CreateUsingNew,
Loki::DeletableSingleton> Gen;
....
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.
 
A

amparikh

Hey, I can't get DeletableSingleton to actually delete the singleton.

The code is:

typedef Loki::SingletonHolder<GenClass Loki::CreateUsingNew,
Loki::DeletableSingleton> Gen;
...
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.
 
S

Shawn McGrath

Hey, Thanks for replying.

I checked everything out, all the examples, and everything seems to be
in order. I have no idea why this is happening =(. I implemented my
own deletable singleton instead of using Loki's. Thanks for the help!

-Shawn.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,269
Latest member
vinaykumar_nevatia23

Latest Threads

Top