mutex.hpp 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Copyright (C) 2000 Stephen Cleary
  2. //
  3. // Distributed under the Boost Software License, Version 1.0. (See
  4. // accompanying file LICENSE_1_0.txt or copy at
  5. // http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // See http://www.boost.org for updates, documentation, and revision history.
  8. #ifndef BOOST_POOL_MUTEX_HPP
  9. #define BOOST_POOL_MUTEX_HPP
  10. #include <boost/config.hpp> // for workarounds
  11. #if defined (BOOST_HAS_THREADS) && !defined(BOOST_POOL_NO_MT)
  12. #if defined (BOOST_NO_CXX11_HDR_MUTEX)
  13. #include <boost/thread/mutex.hpp>
  14. #else
  15. #include <mutex>
  16. #endif
  17. #endif
  18. namespace boost{ namespace details{ namespace pool{
  19. class null_mutex
  20. {
  21. private:
  22. null_mutex(const null_mutex &);
  23. void operator=(const null_mutex &);
  24. public:
  25. null_mutex() { }
  26. static void lock() { }
  27. static void unlock() { }
  28. };
  29. #if !defined(BOOST_HAS_THREADS) || defined(BOOST_NO_MT) || defined(BOOST_POOL_NO_MT)
  30. typedef null_mutex default_mutex;
  31. #else
  32. #if defined (BOOST_NO_CXX11_HDR_MUTEX)
  33. typedef boost::mutex default_mutex;
  34. #else
  35. typedef std::mutex default_mutex;
  36. #endif
  37. #endif
  38. } // namespace pool
  39. } // namespace details
  40. } // namespace boost
  41. #endif