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_EVENT_HPP
12
#define ASIO_DETAIL_POSIX_EVENT_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/assert.hpp>
28
#include <boost/throw_exception.hpp>
30
#include "asio/detail/pop_options.hpp"
32
#include "asio/error.hpp"
33
#include "asio/system_error.hpp"
34
#include "asio/detail/noncopyable.hpp"
47
int error = ::pthread_cond_init(&cond_, 0);
51
asio::error_code(error,
52
asio::error::get_system_category()),
54
boost::throw_exception(e);
61
::pthread_cond_destroy(&cond_);
65
template <typename Lock>
66
void signal(Lock& lock)
68
BOOST_ASSERT(lock.locked());
71
::pthread_cond_signal(&cond_); // Ignore EINVAL.
75
template <typename Lock>
76
void clear(Lock& lock)
78
BOOST_ASSERT(lock.locked());
83
// Wait for the event to become signalled.
84
template <typename Lock>
87
BOOST_ASSERT(lock.locked());
89
::pthread_cond_wait(&cond_, &lock.mutex().mutex_); // Ignore EINVAL.
93
::pthread_cond_t cond_;
100
#endif // defined(BOOST_HAS_PTHREADS)
102
#include "asio/detail/pop_options.hpp"
104
#endif // ASIO_DETAIL_POSIX_EVENT_HPP