]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/asio/detail/impl/win_event.ipp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / asio / detail / impl / win_event.ipp
1 //
2 // detail/win_event.ipp
3 // ~~~~~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2017 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 //
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)
9 //
10
11 #ifndef BOOST_ASIO_DETAIL_IMPL_WIN_EVENT_IPP
12 #define BOOST_ASIO_DETAIL_IMPL_WIN_EVENT_IPP
13
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 # pragma once
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17
18 #include <boost/asio/detail/config.hpp>
19
20 #if defined(BOOST_ASIO_WINDOWS)
21
22 #include <boost/asio/detail/throw_error.hpp>
23 #include <boost/asio/detail/win_event.hpp>
24 #include <boost/asio/error.hpp>
25
26 #include <boost/asio/detail/push_options.hpp>
27
28 namespace boost {
29 namespace asio {
30 namespace detail {
31
32 win_event::win_event()
33 : state_(0)
34 {
35 #if defined(BOOST_ASIO_WINDOWS_APP)
36 events_[0] = ::CreateEventExW(0, 0,
37 CREATE_EVENT_MANUAL_RESET, EVENT_ALL_ACCESS);
38 #else // defined(BOOST_ASIO_WINDOWS_APP)
39 events_[0] = ::CreateEventW(0, true, false, 0);
40 #endif // defined(BOOST_ASIO_WINDOWS_APP)
41 if (!events_[0])
42 {
43 DWORD last_error = ::GetLastError();
44 boost::system::error_code ec(last_error,
45 boost::asio::error::get_system_category());
46 boost::asio::detail::throw_error(ec, "event");
47 }
48
49 #if defined(BOOST_ASIO_WINDOWS_APP)
50 events_[1] = ::CreateEventExW(0, 0, 0, EVENT_ALL_ACCESS);
51 #else // defined(BOOST_ASIO_WINDOWS_APP)
52 events_[1] = ::CreateEventW(0, false, false, 0);
53 #endif // defined(BOOST_ASIO_WINDOWS_APP)
54 if (!events_[1])
55 {
56 DWORD last_error = ::GetLastError();
57 ::CloseHandle(events_[0]);
58 boost::system::error_code ec(last_error,
59 boost::asio::error::get_system_category());
60 boost::asio::detail::throw_error(ec, "event");
61 }
62 }
63
64 win_event::~win_event()
65 {
66 ::CloseHandle(events_[0]);
67 ::CloseHandle(events_[1]);
68 }
69
70 } // namespace detail
71 } // namespace asio
72 } // namespace boost
73
74 #include <boost/asio/detail/pop_options.hpp>
75
76 #endif // defined(BOOST_ASIO_WINDOWS)
77
78 #endif // BOOST_ASIO_DETAIL_IMPL_WIN_EVENT_IPP