2 // detail/impl/posix_event.ipp
3 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 // Copyright (c) 2003-2017 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_IMPL_POSIX_EVENT_IPP
12 #define BOOST_ASIO_DETAIL_IMPL_POSIX_EVENT_IPP
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
18 #include <boost/asio/detail/config.hpp>
20 #if defined(BOOST_ASIO_HAS_PTHREADS)
22 #include <boost/asio/detail/posix_event.hpp>
23 #include <boost/asio/detail/throw_error.hpp>
24 #include <boost/asio/error.hpp>
26 #include <boost/asio/detail/push_options.hpp>
32 posix_event::posix_event()
35 #if (defined(__MACH__) && defined(__APPLE__)) \
36 || (defined(__ANDROID__) && (__ANDROID_API__ < 21))
37 int error = ::pthread_cond_init(&cond_, 0);
38 #else // (defined(__MACH__) && defined(__APPLE__))
39 // || (defined(__ANDROID__) && (__ANDROID_API__ < 21))
40 ::pthread_condattr_t attr;
41 ::pthread_condattr_init(&attr);
42 int error = ::pthread_condattr_setclock(&attr, CLOCK_MONOTONIC);
44 error = ::pthread_cond_init(&cond_, &attr);
45 #endif // (defined(__MACH__) && defined(__APPLE__))
46 // || (defined(__ANDROID__) && (__ANDROID_API__ < 21))
48 boost::system::error_code ec(error,
49 boost::asio::error::get_system_category());
50 boost::asio::detail::throw_error(ec, "event");
57 #include <boost/asio/detail/pop_options.hpp>
59 #endif // defined(BOOST_ASIO_HAS_PTHREADS)
61 #endif // BOOST_ASIO_DETAIL_IMPL_POSIX_EVENT_IPP