473,385 Members | 1,409 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Loki DeletableSingleton

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.

Feb 8 '07 #1
2 2202
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.

Feb 8 '07 #2
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.
On Feb 8, 6:49 pm, ampar...@gmail.com wrote:
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.

Feb 10 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Sebastian Faust | last post by:
Hi, I read about the Loki::Factory and Loki::AbstractFactory in the book Modern C++ Design and couldnt figure out one thing: If I have several classes, for example the following hierarchie: ...
1
by: Dave | last post by:
Is anybody aware of a newsgroup devoted to Loki? I assume this forum would not be the most appropriate place to discuss a specific library, even if that library is written purely in standard...
2
by: Pep | last post by:
The following code from the Loki TypeManip.h header file is causing problems with MSVC version 6.0 template <unsigned i> struct TypeTag { struct Inner {char c;}; typedef Inner X;...
3
by: Krivenok Dmitry | last post by:
I writing simple class CmdLine: ..... ..... class CmdLine { ..... ..... public: /// Constructor CmdLine(int argc, char** argv);
1
by: alex.gman | last post by:
As I understand, Loki has only been partially copied into BOOST. Which parts haven't, and why? Were those considered poorly designed? :-)
3
by: Krivenok Dmitry | last post by:
Hello All! This is example of code: ////////////////////////////////////////////////////////////////////////////////////////////////// #ifndef A_H_ #define A_H_ #include <Loki/Singleton.h>...
2
by: Martin Herbert Dietze | last post by:
Hi, in a project I am using callbacks which are called like ordinary functions but in fact are Loki::Functor's encapsulating calls to non-static member functions on instances of different...
10
by: Ray | last post by:
I am reading Andrei Alexandrescu's book. The ideas presented there sound really good, but I wonder--is there really a lot of people using it? Or it's simply too esoteric for mortals? Cheers Ray
3
by: aaragon | last post by:
Hello everyone, I've been trying to work with the visitor design pattern, and it works fine except for the following. Let's suppose that we have a fixed hierarchy of classes (many of them)...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.