Mercurial > hg > vamp-build-and-test
annotate DEPENDENCIES/generic/include/boost/thread/detail/singleton.hpp @ 125:34e428693f5d vext
Vext -> Repoint
author | Chris Cannam |
---|---|
date | Thu, 14 Jun 2018 11:15:39 +0100 |
parents | 2665513ce2d3 |
children |
rev | line source |
---|---|
Chris@16 | 1 // Copyright (C) 2001-2003 |
Chris@16 | 2 // Mac Murrett |
Chris@16 | 3 // |
Chris@16 | 4 // Distributed under the Boost Software License, Version 1.0. (See |
Chris@16 | 5 // accompanying file LICENSE_1_0.txt or copy at |
Chris@16 | 6 // http://www.boost.org/LICENSE_1_0.txt) |
Chris@16 | 7 // |
Chris@16 | 8 // See http://www.boost.org for most recent version including documentation. |
Chris@16 | 9 |
Chris@16 | 10 #ifndef BOOST_SINGLETON_MJM012402_HPP |
Chris@16 | 11 #define BOOST_SINGLETON_MJM012402_HPP |
Chris@16 | 12 |
Chris@16 | 13 #include <boost/thread/detail/config.hpp> |
Chris@16 | 14 |
Chris@16 | 15 namespace boost { |
Chris@16 | 16 namespace detail { |
Chris@16 | 17 namespace thread { |
Chris@16 | 18 |
Chris@16 | 19 // class singleton has the same goal as all singletons: create one instance of |
Chris@16 | 20 // a class on demand, then dish it out as requested. |
Chris@16 | 21 |
Chris@16 | 22 template <class T> |
Chris@16 | 23 class singleton : private T |
Chris@16 | 24 { |
Chris@16 | 25 private: |
Chris@16 | 26 singleton(); |
Chris@16 | 27 ~singleton(); |
Chris@16 | 28 |
Chris@16 | 29 public: |
Chris@16 | 30 static T &instance(); |
Chris@16 | 31 }; |
Chris@16 | 32 |
Chris@16 | 33 |
Chris@16 | 34 template <class T> |
Chris@16 | 35 inline singleton<T>::singleton() |
Chris@16 | 36 { |
Chris@16 | 37 /* no-op */ |
Chris@16 | 38 } |
Chris@16 | 39 |
Chris@16 | 40 template <class T> |
Chris@16 | 41 inline singleton<T>::~singleton() |
Chris@16 | 42 { |
Chris@16 | 43 /* no-op */ |
Chris@16 | 44 } |
Chris@16 | 45 |
Chris@16 | 46 template <class T> |
Chris@16 | 47 /*static*/ T &singleton<T>::instance() |
Chris@16 | 48 { |
Chris@16 | 49 // function-local static to force this to work correctly at static |
Chris@16 | 50 // initialization time. |
Chris@16 | 51 static singleton<T> s_oT; |
Chris@16 | 52 return(s_oT); |
Chris@16 | 53 } |
Chris@16 | 54 |
Chris@16 | 55 } // namespace thread |
Chris@16 | 56 } // namespace detail |
Chris@16 | 57 } // namespace boost |
Chris@16 | 58 |
Chris@16 | 59 #endif // BOOST_SINGLETON_MJM012402_HPP |