00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef ASIO_DETAIL_WIN_EVENT_HPP
00012 #define ASIO_DETAIL_WIN_EVENT_HPP
00013
00014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
00015 # pragma once
00016 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
00017
00018 #include "asio/detail/push_options.hpp"
00019
00020 #include "asio/detail/push_options.hpp"
00021 #include <boost/config.hpp>
00022 #include "asio/detail/pop_options.hpp"
00023
00024 #if defined(BOOST_WINDOWS)
00025
00026 #include "asio/system_error.hpp"
00027 #include "asio/detail/noncopyable.hpp"
00028 #include "asio/detail/socket_types.hpp"
00029
00030 #include "asio/detail/push_options.hpp"
00031 #include <boost/throw_exception.hpp>
00032 #include "asio/detail/pop_options.hpp"
00033
00034 namespace asio {
00035 namespace detail {
00036
00037 class win_event
00038 : private noncopyable
00039 {
00040 public:
00041
00042 win_event()
00043 : event_(::CreateEvent(0, true, false, 0))
00044 {
00045 if (!event_)
00046 {
00047 DWORD last_error = ::GetLastError();
00048 asio::system_error e(
00049 asio::error_code(last_error, asio::native_ecat),
00050 "event");
00051 boost::throw_exception(e);
00052 }
00053 }
00054
00055
00056 ~win_event()
00057 {
00058 ::CloseHandle(event_);
00059 }
00060
00061
00062 void signal()
00063 {
00064 ::SetEvent(event_);
00065 }
00066
00067
00068 void clear()
00069 {
00070 ::ResetEvent(event_);
00071 }
00072
00073
00074 void wait()
00075 {
00076 ::WaitForSingleObject(event_, INFINITE);
00077 }
00078
00079 private:
00080 HANDLE event_;
00081 };
00082
00083 }
00084 }
00085
00086 #endif // defined(BOOST_WINDOWS)
00087
00088 #include "asio/detail/pop_options.hpp"
00089
00090 #endif // ASIO_DETAIL_WIN_EVENT_HPP