1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/ossrv_pub/boost_apis/boost/thread/detail/singleton.hpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,59 @@
1.4 +// Copyright (C) 2001-2003
1.5 +// Mac Murrett
1.6 +//
1.7 +// Distributed under the Boost Software License, Version 1.0. (See
1.8 +// accompanying file LICENSE_1_0.txt or copy at
1.9 +// http://www.boost.org/LICENSE_1_0.txt)
1.10 +//
1.11 +// See http://www.boost.org for most recent version including documentation.
1.12 +
1.13 +#ifndef BOOST_SINGLETON_MJM012402_HPP
1.14 +#define BOOST_SINGLETON_MJM012402_HPP
1.15 +
1.16 +#include <boost/thread/detail/config.hpp>
1.17 +
1.18 +namespace boost {
1.19 +namespace detail {
1.20 +namespace thread {
1.21 +
1.22 +// class singleton has the same goal as all singletons: create one instance of
1.23 +// a class on demand, then dish it out as requested.
1.24 +
1.25 +template <class T>
1.26 +class singleton : private T
1.27 +{
1.28 +private:
1.29 + singleton();
1.30 + ~singleton();
1.31 +
1.32 +public:
1.33 + static T &instance();
1.34 +};
1.35 +
1.36 +
1.37 +template <class T>
1.38 +inline singleton<T>::singleton()
1.39 +{
1.40 + /* no-op */
1.41 +}
1.42 +
1.43 +template <class T>
1.44 +inline singleton<T>::~singleton()
1.45 +{
1.46 + /* no-op */
1.47 +}
1.48 +
1.49 +template <class T>
1.50 +/*static*/ T &singleton<T>::instance()
1.51 +{
1.52 + // function-local static to force this to work correctly at static
1.53 + // initialization time.
1.54 + static singleton<T> s_oT;
1.55 + return(s_oT);
1.56 +}
1.57 +
1.58 +} // namespace thread
1.59 +} // namespace detail
1.60 +} // namespace boost
1.61 +
1.62 +#endif // BOOST_SINGLETON_MJM012402_HPP