Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/asio/detail/win_event.hpp @ 16:2665513ce2d3
Add boost headers
author | Chris Cannam |
---|---|
date | Tue, 05 Aug 2014 11:11:38 +0100 |
parents | |
children | c530137014c0 |
comparison
equal
deleted
inserted
replaced
15:663ca0da4350 | 16:2665513ce2d3 |
---|---|
1 // | |
2 // detail/win_event.hpp | |
3 // ~~~~~~~~~~~~~~~~~~~~ | |
4 // | |
5 // Copyright (c) 2003-2013 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_WIN_EVENT_HPP | |
12 #define BOOST_ASIO_DETAIL_WIN_EVENT_HPP | |
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/assert.hpp> | |
23 #include <boost/asio/detail/noncopyable.hpp> | |
24 #include <boost/asio/detail/socket_types.hpp> | |
25 | |
26 #include <boost/asio/detail/push_options.hpp> | |
27 | |
28 namespace boost { | |
29 namespace asio { | |
30 namespace detail { | |
31 | |
32 class win_event | |
33 : private noncopyable | |
34 { | |
35 public: | |
36 // Constructor. | |
37 BOOST_ASIO_DECL win_event(); | |
38 | |
39 // Destructor. | |
40 ~win_event() | |
41 { | |
42 ::CloseHandle(event_); | |
43 } | |
44 | |
45 // Signal the event. | |
46 template <typename Lock> | |
47 void signal(Lock& lock) | |
48 { | |
49 BOOST_ASIO_ASSERT(lock.locked()); | |
50 (void)lock; | |
51 ::SetEvent(event_); | |
52 } | |
53 | |
54 // Signal the event and unlock the mutex. | |
55 template <typename Lock> | |
56 void signal_and_unlock(Lock& lock) | |
57 { | |
58 BOOST_ASIO_ASSERT(lock.locked()); | |
59 lock.unlock(); | |
60 ::SetEvent(event_); | |
61 } | |
62 | |
63 // Reset the event. | |
64 template <typename Lock> | |
65 void clear(Lock& lock) | |
66 { | |
67 BOOST_ASIO_ASSERT(lock.locked()); | |
68 (void)lock; | |
69 ::ResetEvent(event_); | |
70 } | |
71 | |
72 // Wait for the event to become signalled. | |
73 template <typename Lock> | |
74 void wait(Lock& lock) | |
75 { | |
76 BOOST_ASIO_ASSERT(lock.locked()); | |
77 lock.unlock(); | |
78 ::WaitForSingleObject(event_, INFINITE); | |
79 lock.lock(); | |
80 } | |
81 | |
82 private: | |
83 HANDLE event_; | |
84 }; | |
85 | |
86 } // namespace detail | |
87 } // namespace asio | |
88 } // namespace boost | |
89 | |
90 #include <boost/asio/detail/pop_options.hpp> | |
91 | |
92 #if defined(BOOST_ASIO_HEADER_ONLY) | |
93 # include <boost/asio/detail/impl/win_event.ipp> | |
94 #endif // defined(BOOST_ASIO_HEADER_ONLY) | |
95 | |
96 #endif // defined(BOOST_ASIO_WINDOWS) | |
97 | |
98 #endif // BOOST_ASIO_DETAIL_WIN_EVENT_HPP |