2 // detail/win_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_WIN_EVENT_IPP
12 #define BOOST_ASIO_DETAIL_IMPL_WIN_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_WINDOWS)
22 #include <boost/asio/detail/throw_error.hpp>
23 #include <boost/asio/detail/win_event.hpp>
24 #include <boost/asio/error.hpp>
26 #include <boost/asio/detail/push_options.hpp>
32 win_event::win_event()
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)
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");
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)
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");
64 win_event::~win_event()
66 ::CloseHandle(events_[0]);
67 ::CloseHandle(events_[1]);
74 #include <boost/asio/detail/pop_options.hpp>
76 #endif // defined(BOOST_ASIO_WINDOWS)
78 #endif // BOOST_ASIO_DETAIL_IMPL_WIN_EVENT_IPP