[pool] Singleton implementation

Hi all, I am interested to find a sound C++ implementation of a Singleton, and have attempted to find one within the Boost libraries. It seems that "pool/detail/singleton.hpp" would fit the bill for me, but (as I understand it) this class/header is not intended for direct use by library users. Have I overlooked a good alternative within the Boost suite? Thanks, Paul

I am interested to find a sound C++ implementation of a Singleton, and have attempted to find one within the Boost libraries. It seems that "pool/detail/singleton.hpp" would fit the bill for me, but (as I understand it) this class/header is not intended for direct use by library users. Have I overlooked a good alternative within the Boost suite?
I don't think there is something in boost. Here is some research I did on Singletons: http://www.oneunified.net/blog/Personal/SoftwareDevelopment/CPP/Singleton.ar ticle http://www.oneunified.net/blog/Personal/SoftwareDevelopment/CPP/SingletonPer Thread.article -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.

You could try: http://www.boostcookbook.com/Recipe:/1235044 Kind regards, Derik On Tue, 2009-10-20 at 08:59 -0300, Ray Burkholder wrote:
I am interested to find a sound C++ implementation of a Singleton, and have attempted to find one within the Boost libraries. It seems that "pool/detail/singleton.hpp" would fit the bill for me, but (as I understand it) this class/header is not intended for direct use by library users. Have I overlooked a good alternative within the Boost suite?
I don't think there is something in boost. Here is some research I did on Singletons: http://www.oneunified.net/blog/Personal/SoftwareDevelopment/CPP/Singleton.ar ticle http://www.oneunified.net/blog/Personal/SoftwareDevelopment/CPP/SingletonPer Thread.article

FWIW. I occasionally use a scheme in the Loki library. For my needs it was
simple and worked.
I have not run into any coexistence problems with Boost (1.32 through 1.40
on Windows with
MSVC 6, 7, 8, or 9).
Larry
----- Original Message -----
From: "Ray Burkholder"
I am interested to find a sound C++ implementation of a Singleton, and have attempted to find one within the Boost libraries. It seems that "pool/detail/singleton.hpp" would fit the bill for me, but (as I understand it) this class/header is not intended for direct use by library users. Have I overlooked a good alternative within the Boost suite?
I don't think there is something in boost. Here is some research I did on Singletons: http://www.oneunified.net/blog/Personal/SoftwareDevelopment/CPP/Singleton.ar ticle http://www.oneunified.net/blog/Personal/SoftwareDevelopment/CPP/SingletonPer Thread.article
-- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Larry wrote:
FWIW. I occasionally use a scheme in the Loki library. For my needs it was simple and worked. I have not run into any coexistence problems with Boost (1.32 through 1.40 on Windows with MSVC 6, 7, 8, or 9).
I have used Loki stuff too. Under windows, if you're using DLLs though, you will need some magic incantations to keep from having multiple copies of the Singleton appear. Basically, you need to ensure the templates (which contain static data) get instantiated only once.

Eric J. Holtman wrote:
Larry wrote:
FWIW. I occasionally use a scheme in the Loki library. For my needs it was simple and worked. I have not run into any coexistence problems with Boost (1.32 through 1.40 on Windows with MSVC 6, 7, 8, or 9).
I have used Loki stuff too. Under windows, if you're using DLLs though, you will need some magic incantations to keep from having multiple copies of the Singleton appear.
This is not unique to windows - same issue with linux and I presume others.
Basically, you need to ensure the templates (which contain static data) get instantiated only once.
how do you do this? Robert Ramey

Robert Ramey wrote:
Basically, you need to ensure the templates (which contain static data) get instantiated only once.
how do you do this?
This is not a Loki mailing list, so I don't want to chew up tons of bandwidth, but you can look at SingletonDLL under their distribution for hints. I've found that there's still some wonky-ness with Microsoft's compiler, and so I pretty much gave up on trying to globally fix the issues, and ending up having actual concrete classes for my factories, which inside their .cpp implemetation files used the templated Singletons in an anonymous namespace. That way, the templates only ever appear in implemetation files, but not in headers, so I only get one copy. Maybe someday I'll go back and re-visit the issue, but the last time I looked into it, I was more interested in "a solution for Eric's programs" than the "100% correct solution for everyone's programs".

You might want to look at the singleton which is part of the serialization library. Robert Ramey Paul Byrne wrote:
Hi all,
I am interested to find a sound C++ implementation of a Singleton, and have attempted to find one within the Boost libraries. It seems that "pool/detail/singleton.hpp" would fit the bill for me, but (as I understand it) this class/header is not intended for direct use by library users. Have I overlooked a good alternative within the Boost suite?
Thanks, Paul
participants (6)
-
Eric J. Holtman
-
J.W.F. Thirion
-
Larry
-
Paul Byrne
-
Ray Burkholder
-
Robert Ramey