Singleton implementation
Zack Rusin
zack at kde.org
Wed Jul 9 16:48:33 BST 2003
On Wednesday 09 July 2003 04:42, Simon Hausmann wrote:
> As much as I'd like to see a good re-usable template for singletons
> (I was excited, too, about putting this into kdelibs, when I read
> the book :) as much I'm afraid it's of very limited use for us. The
> way the destruction is designed with atexit prevents the use of the
> template in a library. Apart from very interesting points made by
> Havoc on the use of atexit in libraries --
> http://mail.gnome.org/archives/gnome-components-list/2001-October/msg
>00083.html -- there is another problem: Noone calls the function you
> registered with atexit when dlclosing the library the function is in.
This one wouldn't be a problem, since that's why I added
KDEDefaultLifetime which can function without atexit. I added it there
to perform the cleanup on the spot but could just leave to KGlobal to
clean it up. We could comment out other policies and use only that one.
> Another point is that if you put the typedef in your publically
> installed header file in a library noone can guarantee that all
> methods and static variables (thinking of mpInstance and instance()
> itself) are emitted next to the actual class implementation
> (YourClass) , which however is necessary for proper function (like
> for example if you use static objects instead of atexit for
> destruction) .
This one is more worriedsome and quite frankly I'm at a lost whether it
could be solved :(
Thanks for your comments Simon.
Zack
--
The reason we nerds dominate is . . . Oh, wait, Is that beer?
More information about the kde-core-devel
mailing list