5 // Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com)
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)
11 #ifndef BOOST_ASIO_DETAIL_POSIX_MUTEX_HPP
12 #define BOOST_ASIO_DETAIL_POSIX_MUTEX_HPP
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
18 #include <boost/asio/detail/push_options.hpp>
20 #include <boost/asio/detail/push_options.hpp>
21 #include <boost/config.hpp>
22 #include <boost/system/system_error.hpp>
23 #include <boost/asio/detail/pop_options.hpp>
25 #if defined(BOOST_HAS_PTHREADS)
27 #include <boost/asio/detail/push_options.hpp>
28 #include <boost/throw_exception.hpp>
30 #include <boost/asio/detail/pop_options.hpp>
32 #include <boost/asio/error.hpp>
33 #include <boost/asio/detail/noncopyable.hpp>
34 #include <boost/asio/detail/scoped_lock.hpp>
46 typedef boost::asio::detail::scoped_lock
<posix_mutex
> scoped_lock
;
51 int error
= ::pthread_mutex_init(&mutex_
, 0);
54 boost::system::system_error
e(
55 boost::system::error_code(error
,
56 boost::asio::error::get_system_category()),
58 boost::throw_exception(e
);
65 ::pthread_mutex_destroy(&mutex_
);
71 int error
= ::pthread_mutex_lock(&mutex_
);
74 boost::system::system_error
e(
75 boost::system::error_code(error
,
76 boost::asio::error::get_system_category()),
78 boost::throw_exception(e
);
85 int error
= ::pthread_mutex_unlock(&mutex_
);
88 boost::system::system_error
e(
89 boost::system::error_code(error
,
90 boost::asio::error::get_system_category()),
92 boost::throw_exception(e
);
97 friend class posix_event
;
98 ::pthread_mutex_t mutex_
;
101 } // namespace detail
105 #endif // defined(BOOST_HAS_PTHREADS)
107 #include <boost/asio/detail/pop_options.hpp>
109 #endif // BOOST_ASIO_DETAIL_POSIX_MUTEX_HPP