Boost logo

Boost :

From: Thomas Matelich (sosedada_at_[hidden])
Date: 2001-07-23 12:21:25

scleary_at_[hidden] wrote:

> From: Vesa Karvonen <vesa.karvonen_at_[hidden]>
> > From: "Greg Colvin" <gcolvin_at_[hidden]>
> > > Anyway, a simple template for this idiom might be a useful addition to
> > > Boost.
> >
> > I believe a simple template might cause more problems than it would solve.
> For
> > instance, neither of the above are thread safe, and the destruction order
> can
> > still cause problems.
> There doesn't exist a "simple template" solution. FYI, Boost.Pool has a
> convoluted template solution for its particular singleton needs; it's under
> <boost/pool/detail/singleton.hpp>, if anyone's interested.
> It has the following properties:
> . If the singleton instance is never referenced, then it's never created.
> . The singleton is created before main() begins if it is referenced, and is
> destroyed after main() ends; thus, it can be thread safe IF there is only
> one thread running at those times. (It does *not* use the double-checked
> locking idiom).
> . The singleton may be safely referenced by any global object constructor;
> initialization order has no effect.
> and the following restrictions:
> . No special behaviour is provided for singleton destruction; the intention
> is that if the singleton is required in a global object's destructor, then
> put a reference to it in the constructor.
> . The code for Boost.Pool's singleton only supports singleton types with
> default constructors.
> This header has the intent that it will eventually be replaced by a
> Boost.Singleton library. Which no-one has been brave enough to try :)
> -Steve
> Info: Unsubscribe: <mailto:boost-unsubscribe_at_[hidden]>
> Your use of Yahoo! Groups is subject to

There is a singleton template in the vault b Branko Cibej. I used it for a while when
it was first posted. It will enforce some construction order things for you, but I
ended up taking it out of my code because I didn't need any of the extra features it
offered and I didn't like the typedefs involved.

Thomas O Matelich
Senior Software Designer
Zetec, Inc.

Boost list run by bdawes at, gregod at, cpdaniel at, john at