diff options
author | philip.liard@gmail.com <philip.liard@gmail.com@ee073f10-1060-11df-b6a4-87a95322a99c> | 2013-06-17 11:53:01 +0000 |
---|---|---|
committer | philip.liard@gmail.com <philip.liard@gmail.com@ee073f10-1060-11df-b6a4-87a95322a99c> | 2013-06-17 11:53:01 +0000 |
commit | b886df44145f2b98006e6f394c4fbe0a5892c9a2 (patch) | |
tree | 829ebea4cef48ca5a13d1c46f47f297db8a7e8e0 /base/memory/singleton.h | |
parent | 8e2480799f0c4c3004c8ee393c2277d25e232862 (diff) | |
download | phonenumbers-b886df44145f2b98006e6f394c4fbe0a5892c9a2.tar.gz |
CPP: Add suport for thread-safety on Linux and Mac in non-Boost base/.
This is needed for Chrome on Android which is the only Chrome port that
requires thread-safety.
R=lararennie@google.com
Review URL: https://codereview.appspot.com/10244046
git-svn-id: http://libphonenumber.googlecode.com/svn/trunk/cpp/src/phonenumbers@583 ee073f10-1060-11df-b6a4-87a95322a99c
Diffstat (limited to 'base/memory/singleton.h')
-rw-r--r-- | base/memory/singleton.h | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/base/memory/singleton.h b/base/memory/singleton.h index 38b4bfc..5fd3e4c 100644 --- a/base/memory/singleton.h +++ b/base/memory/singleton.h @@ -14,8 +14,8 @@ // Author: Philippe Liard -#ifndef I18N_PHONENUMBERS_BASE_SINGLETON_H_ -#define I18N_PHONENUMBERS_BASE_SINGLETON_H_ +#ifndef I18N_PHONENUMBERS_BASE_MEMORY_SINGLETON_H_ +#define I18N_PHONENUMBERS_BASE_MEMORY_SINGLETON_H_ #if defined(I18N_PHONENUMBERS_USE_BOOST) @@ -48,16 +48,22 @@ class Singleton : private boost::noncopyable { template <class T> boost::scoped_ptr<T> Singleton<T>::instance; template <class T> boost::once_flag Singleton<T>::flag = BOOST_ONCE_INIT; +} // namespace phonenumbers +} // namespace i18n + #else // !I18N_PHONENUMBERS_USE_BOOST #include "phonenumbers/base/logging.h" #include "phonenumbers/base/thread_checker.h" +#if !defined(__linux__) && !defined(__APPLE__) + namespace i18n { namespace phonenumbers { // Note that this implementation is not thread-safe. For a thread-safe -// implementation, please compile with -DI18N_PHONENUMBERS_USE_BOOST. +// implementation on non-POSIX platforms, please compile with +// -DI18N_PHONENUMBERS_USE_BOOST. template <class T> class Singleton { public: @@ -78,9 +84,12 @@ class Singleton { const ThreadChecker thread_checker_; }; -#endif // !I18N_PHONENUMBERS_USE_BOOST - } // namespace phonenumbers } // namespace i18n -#endif // I18N_PHONENUMBERS_BASE_SINGLETON_H_ +#else +#include "phonenumbers/base/memory/singleton_posix.h" +#endif // !defined(__linux__) && !defined(__APPLE__) + +#endif // !I18N_PHONENUMBERS_USE_BOOST +#endif // I18N_PHONENUMBERS_BASE_MEMORY_SINGLETON_H_ |