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 ASIO_DETAIL_POSIX_MUTEX_HPP
12
#define ASIO_DETAIL_POSIX_MUTEX_HPP
14
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
16
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
18
#include "asio/detail/push_options.hpp"
20
#include "asio/detail/push_options.hpp"
21
#include <boost/config.hpp>
22
#include "asio/detail/pop_options.hpp"
24
#if defined(BOOST_HAS_PTHREADS)
26
#include "asio/detail/push_options.hpp"
27
#include <boost/throw_exception.hpp>
29
#include "asio/detail/pop_options.hpp"
31
#include "asio/error.hpp"
32
#include "asio/system_error.hpp"
33
#include "asio/detail/noncopyable.hpp"
34
#include "asio/detail/scoped_lock.hpp"
45
typedef asio::detail::scoped_lock<posix_mutex> scoped_lock;
50
int error = ::pthread_mutex_init(&mutex_, 0);
54
asio::error_code(error,
55
asio::error::get_system_category()),
57
boost::throw_exception(e);
64
::pthread_mutex_destroy(&mutex_);
70
int error = ::pthread_mutex_lock(&mutex_);
74
asio::error_code(error,
75
asio::error::get_system_category()),
77
boost::throw_exception(e);
84
int error = ::pthread_mutex_unlock(&mutex_);
88
asio::error_code(error,
89
asio::error::get_system_category()),
91
boost::throw_exception(e);
96
friend class posix_event;
97
::pthread_mutex_t mutex_;
100
} // namespace detail
103
#endif // defined(BOOST_HAS_PTHREADS)
105
#include "asio/detail/pop_options.hpp"
107
#endif // ASIO_DETAIL_POSIX_MUTEX_HPP