Boost logo

Boost Users :

Subject: Re: [Boost-users] thread-safe initialization for singleton
From: Mika Heiskanen (mika.heiskanen_at_[hidden])
Date: 2010-08-22 03:18:21


On Sun, 2010-08-22 at 09:33 +0300, Kraus Philipp wrote:

> > > > > I use boost::thread for implementating the threads. I have
> > > > > found
> > > > > boost_once but I don't know how to use it, so my class
> > > > > properties are
> > > > > initialized once.
> > > >
> > > > http://www.google.com/search?q=boost_once+singleton
> > >
> > > I know Google and so I've found boost_once, but can you show me a
> > > little
> > > example?
> >
> > He was hinting at something, look at the very first result on that
> > Google link.
> The first example? I need only to implementate the boost::noncopyable
> and the
> this strucutres
> template<class T> boost::scoped_ptr<T> Templates::Singleton<T>::t(0);
> template<class T> boost::once_flag Templates::Singleton<T>::flag = BOOST_ONCE_INIT;
> ?
> I've found many example that descripe more code like this
>
> http://blog.defx.de/2008/12/07/singletons-und-thread-locks-via-boost/ !?

Your link does not use boost_once, and you specifically asked for a
boost_once example on how to implement a singleton.

--> Mika Heiskanen


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net