2018-12-31 20:04:05 +01:00
|
|
|
//
|
2018-01-02 14:42:31 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2018
|
2018-12-31 20:04:05 +01:00
|
|
|
//
|
|
|
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
//
|
|
|
|
#include "td/utils/port/detail/EventFdWindows.h"
|
|
|
|
|
|
|
|
char disable_linker_warning_about_empty_file_event_fd_windows_cpp TD_UNUSED;
|
|
|
|
|
|
|
|
#ifdef TD_EVENTFD_WINDOWS
|
|
|
|
|
2018-09-10 03:08:15 +02:00
|
|
|
#include "td/utils/logging.h"
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
namespace td {
|
|
|
|
namespace detail {
|
|
|
|
|
|
|
|
void EventFdWindows::init() {
|
2018-08-13 19:15:09 +02:00
|
|
|
event_ = NativeFd(CreateEventW(nullptr, true, false, nullptr));
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
bool EventFdWindows::empty() {
|
2018-08-13 19:15:09 +02:00
|
|
|
return !event_;
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void EventFdWindows::close() {
|
2018-08-13 19:15:09 +02:00
|
|
|
event_.close();
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Status EventFdWindows::get_pending_error() {
|
|
|
|
return Status::OK();
|
|
|
|
}
|
|
|
|
|
2018-08-13 19:15:09 +02:00
|
|
|
PollableFdInfo &EventFdWindows::get_poll_info() {
|
|
|
|
UNREACHABLE();
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void EventFdWindows::release() {
|
2018-08-13 19:15:09 +02:00
|
|
|
SetEvent(event_.io_handle());
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void EventFdWindows::acquire() {
|
2018-08-13 19:15:09 +02:00
|
|
|
ResetEvent(event_.io_handle());
|
|
|
|
}
|
|
|
|
|
|
|
|
void EventFdWindows::wait(int timeout_ms) {
|
|
|
|
WaitForSingleObject(event_.io_handle(), timeout_ms);
|
|
|
|
ResetEvent(event_.io_handle());
|
2018-12-31 20:04:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace detail
|
|
|
|
} // namespace td
|
|
|
|
|
|
|
|
#endif
|