2 // detail/win_event.ipp
3 // ~~~~~~~~~~~~~~~~~~~~
5 // Copyright (c) 2003-2016 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, CREATE_EVENT_MANUAL_RESET, 0);
37 #else // defined(BOOST_ASIO_WINDOWS_APP)
38 events_[0] = ::CreateEventW(0, true, false, 0);
39 #endif // defined(BOOST_ASIO_WINDOWS_APP)
42 DWORD last_error = ::GetLastError();
43 boost::system::error_code ec(last_error,
44 boost::asio::error::get_system_category());
45 boost::asio::detail::throw_error(ec, "event");
48 #if defined(BOOST_ASIO_WINDOWS_APP)
49 events_[1] = ::CreateEventExW(0, 0, 0, 0);
50 #else // defined(BOOST_ASIO_WINDOWS_APP)
51 events_[1] = ::CreateEventW(0, false, false, 0);
52 #endif // defined(BOOST_ASIO_WINDOWS_APP)
55 DWORD last_error = ::GetLastError();
56 ::CloseHandle(events_[0]);
57 boost::system::error_code ec(last_error,
58 boost::asio::error::get_system_category());
59 boost::asio::detail::throw_error(ec, "event");
63 win_event::~win_event()
65 ::CloseHandle(events_[0]);
66 ::CloseHandle(events_[1]);
73 #include <boost/asio/detail/pop_options.hpp>
75 #endif // defined(BOOST_ASIO_WINDOWS)
77 #endif // BOOST_ASIO_DETAIL_IMPL_WIN_EVENT_IPP