annotate 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
rev   line source
Chris@16 1 //
Chris@16 2 // detail/win_event.hpp
Chris@16 3 // ~~~~~~~~~~~~~~~~~~~~
Chris@16 4 //
Chris@16 5 // Copyright (c) 2003-2013 Christopher M. Kohlhoff (chris at kohlhoff dot com)
Chris@16 6 //
Chris@16 7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
Chris@16 8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 9 //
Chris@16 10
Chris@16 11 #ifndef BOOST_ASIO_DETAIL_WIN_EVENT_HPP
Chris@16 12 #define BOOST_ASIO_DETAIL_WIN_EVENT_HPP
Chris@16 13
Chris@16 14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
Chris@16 15 # pragma once
Chris@16 16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
Chris@16 17
Chris@16 18 #include <boost/asio/detail/config.hpp>
Chris@16 19
Chris@16 20 #if defined(BOOST_ASIO_WINDOWS)
Chris@16 21
Chris@16 22 #include <boost/asio/detail/assert.hpp>
Chris@16 23 #include <boost/asio/detail/noncopyable.hpp>
Chris@16 24 #include <boost/asio/detail/socket_types.hpp>
Chris@16 25
Chris@16 26 #include <boost/asio/detail/push_options.hpp>
Chris@16 27
Chris@16 28 namespace boost {
Chris@16 29 namespace asio {
Chris@16 30 namespace detail {
Chris@16 31
Chris@16 32 class win_event
Chris@16 33 : private noncopyable
Chris@16 34 {
Chris@16 35 public:
Chris@16 36 // Constructor.
Chris@16 37 BOOST_ASIO_DECL win_event();
Chris@16 38
Chris@16 39 // Destructor.
Chris@16 40 ~win_event()
Chris@16 41 {
Chris@16 42 ::CloseHandle(event_);
Chris@16 43 }
Chris@16 44
Chris@16 45 // Signal the event.
Chris@16 46 template <typename Lock>
Chris@16 47 void signal(Lock& lock)
Chris@16 48 {
Chris@16 49 BOOST_ASIO_ASSERT(lock.locked());
Chris@16 50 (void)lock;
Chris@16 51 ::SetEvent(event_);
Chris@16 52 }
Chris@16 53
Chris@16 54 // Signal the event and unlock the mutex.
Chris@16 55 template <typename Lock>
Chris@16 56 void signal_and_unlock(Lock& lock)
Chris@16 57 {
Chris@16 58 BOOST_ASIO_ASSERT(lock.locked());
Chris@16 59 lock.unlock();
Chris@16 60 ::SetEvent(event_);
Chris@16 61 }
Chris@16 62
Chris@16 63 // Reset the event.
Chris@16 64 template <typename Lock>
Chris@16 65 void clear(Lock& lock)
Chris@16 66 {
Chris@16 67 BOOST_ASIO_ASSERT(lock.locked());
Chris@16 68 (void)lock;
Chris@16 69 ::ResetEvent(event_);
Chris@16 70 }
Chris@16 71
Chris@16 72 // Wait for the event to become signalled.
Chris@16 73 template <typename Lock>
Chris@16 74 void wait(Lock& lock)
Chris@16 75 {
Chris@16 76 BOOST_ASIO_ASSERT(lock.locked());
Chris@16 77 lock.unlock();
Chris@16 78 ::WaitForSingleObject(event_, INFINITE);
Chris@16 79 lock.lock();
Chris@16 80 }
Chris@16 81
Chris@16 82 private:
Chris@16 83 HANDLE event_;
Chris@16 84 };
Chris@16 85
Chris@16 86 } // namespace detail
Chris@16 87 } // namespace asio
Chris@16 88 } // namespace boost
Chris@16 89
Chris@16 90 #include <boost/asio/detail/pop_options.hpp>
Chris@16 91
Chris@16 92 #if defined(BOOST_ASIO_HEADER_ONLY)
Chris@16 93 # include <boost/asio/detail/impl/win_event.ipp>
Chris@16 94 #endif // defined(BOOST_ASIO_HEADER_ONLY)
Chris@16 95
Chris@16 96 #endif // defined(BOOST_ASIO_WINDOWS)
Chris@16 97
Chris@16 98 #endif // BOOST_ASIO_DETAIL_WIN_EVENT_HPP