File indexing completed on 2025-01-18 09:28:42
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_ASIO_DETAIL_POSIX_MUTEX_HPP
0012 #define BOOST_ASIO_DETAIL_POSIX_MUTEX_HPP
0013
0014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0015 # pragma once
0016 #endif
0017
0018 #include <boost/asio/detail/config.hpp>
0019
0020 #if defined(BOOST_ASIO_HAS_PTHREADS)
0021
0022 #include <pthread.h>
0023 #include <boost/asio/detail/noncopyable.hpp>
0024 #include <boost/asio/detail/scoped_lock.hpp>
0025
0026 #include <boost/asio/detail/push_options.hpp>
0027
0028 namespace boost {
0029 namespace asio {
0030 namespace detail {
0031
0032 class posix_event;
0033
0034 class posix_mutex
0035 : private noncopyable
0036 {
0037 public:
0038 typedef boost::asio::detail::scoped_lock<posix_mutex> scoped_lock;
0039
0040
0041 BOOST_ASIO_DECL posix_mutex();
0042
0043
0044 ~posix_mutex()
0045 {
0046 ::pthread_mutex_destroy(&mutex_);
0047 }
0048
0049
0050 void lock()
0051 {
0052 (void)::pthread_mutex_lock(&mutex_);
0053 }
0054
0055
0056 void unlock()
0057 {
0058 (void)::pthread_mutex_unlock(&mutex_);
0059 }
0060
0061 private:
0062 friend class posix_event;
0063 ::pthread_mutex_t mutex_;
0064 };
0065
0066 }
0067 }
0068 }
0069
0070 #include <boost/asio/detail/pop_options.hpp>
0071
0072 #if defined(BOOST_ASIO_HEADER_ONLY)
0073 # include <boost/asio/detail/impl/posix_mutex.ipp>
0074 #endif
0075
0076 #endif
0077
0078 #endif