This repository has been archived on 2020-05-25. You can view files and clone it, but cannot push or open issues or pull requests.
tdlib-fork/tdutils/td/utils/port/detail/EventFdWindows.cpp
levlam 10118d0449 Simplify NativeFd.
GitOrigin-RevId: 07a33f1ad18b426ef339da76467c667607c1a3b9
2018-09-11 16:27:20 +03:00

55 lines
1.1 KiB
C++

//
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2018
//
// 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
#include "td/utils/logging.h"
namespace td {
namespace detail {
void EventFdWindows::init() {
event_ = NativeFd(CreateEventW(nullptr, true, false, nullptr));
}
bool EventFdWindows::empty() {
return !event_;
}
void EventFdWindows::close() {
event_.close();
}
Status EventFdWindows::get_pending_error() {
return Status::OK();
}
PollableFdInfo &EventFdWindows::get_poll_info() {
UNREACHABLE();
}
void EventFdWindows::release() {
SetEvent(event_.fd());
}
void EventFdWindows::acquire() {
ResetEvent(event_.fd());
}
void EventFdWindows::wait(int timeout_ms) {
WaitForSingleObject(event_.fd(), timeout_ms);
ResetEvent(event_.fd());
}
} // namespace detail
} // namespace td
#endif