static_mutex.hpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. //
  2. // detail/static_mutex.hpp
  3. // ~~~~~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2021 Christopher M. Kohlhoff (chris at kohlhoff dot com)
  6. //
  7. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  8. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  9. //
  10. #ifndef BOOST_ASIO_DETAIL_STATIC_MUTEX_HPP
  11. #define BOOST_ASIO_DETAIL_STATIC_MUTEX_HPP
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  15. #include <boost/asio/detail/config.hpp>
  16. #if !defined(BOOST_ASIO_HAS_THREADS)
  17. # include <boost/asio/detail/null_static_mutex.hpp>
  18. #elif defined(BOOST_ASIO_WINDOWS)
  19. # include <boost/asio/detail/win_static_mutex.hpp>
  20. #elif defined(BOOST_ASIO_HAS_PTHREADS)
  21. # include <boost/asio/detail/posix_static_mutex.hpp>
  22. #elif defined(BOOST_ASIO_HAS_STD_MUTEX_AND_CONDVAR)
  23. # include <boost/asio/detail/std_static_mutex.hpp>
  24. #else
  25. # error Only Windows and POSIX are supported!
  26. #endif
  27. namespace boost {
  28. namespace asio {
  29. namespace detail {
  30. #if !defined(BOOST_ASIO_HAS_THREADS)
  31. typedef null_static_mutex static_mutex;
  32. # define BOOST_ASIO_STATIC_MUTEX_INIT BOOST_ASIO_NULL_STATIC_MUTEX_INIT
  33. #elif defined(BOOST_ASIO_WINDOWS)
  34. typedef win_static_mutex static_mutex;
  35. # define BOOST_ASIO_STATIC_MUTEX_INIT BOOST_ASIO_WIN_STATIC_MUTEX_INIT
  36. #elif defined(BOOST_ASIO_HAS_PTHREADS)
  37. typedef posix_static_mutex static_mutex;
  38. # define BOOST_ASIO_STATIC_MUTEX_INIT BOOST_ASIO_POSIX_STATIC_MUTEX_INIT
  39. #elif defined(BOOST_ASIO_HAS_STD_MUTEX_AND_CONDVAR)
  40. typedef std_static_mutex static_mutex;
  41. # define BOOST_ASIO_STATIC_MUTEX_INIT BOOST_ASIO_STD_STATIC_MUTEX_INIT
  42. #endif
  43. } // namespace detail
  44. } // namespace asio
  45. } // namespace boost
  46. #endif // BOOST_ASIO_DETAIL_STATIC_MUTEX_HPP