Commit 9e97acc2 authored by Max Kellermann's avatar Max Kellermann

event/WinSelect: merge duplicate code into ApplyReady()

parent b1e446a9
......@@ -117,6 +117,14 @@ WinSelectBackend::Remove(SOCKET fd) noexcept
return true;
}
void
WinSelectBackend::ApplyReady(const SocketSet &src, unsigned events) noexcept
{
for (const auto i : src) {
items[i].events |= events;
}
}
PollResultGeneric
WinSelectBackend::ReadEvents(int timeout_ms) noexcept
{
......@@ -148,14 +156,9 @@ WinSelectBackend::ReadEvents(int timeout_ms) noexcept
if (ret == 0 || ret == SOCKET_ERROR)
return result;
for (const auto i : read_set)
items[i].events |= WinSelectEvents::READ;
for (const auto i : write_set)
items[i].events |= WinSelectEvents::WRITE;
for (const auto i : except_set)
items[i].events |= WinSelectEvents::WRITE;
ApplyReady(read_set, WinSelectEvents::READ);
ApplyReady(write_set, WinSelectEvents::WRITE);
ApplyReady(except_set, WinSelectEvents::WRITE);
for (auto &i : items)
if (i.second.events != 0) {
......
......@@ -119,6 +119,8 @@ private:
int event_id) const noexcept;
void Modify(Item &item, SOCKET fd, unsigned events,
int event_id) noexcept;
void ApplyReady(const SocketSet &src, unsigned events) noexcept;
};
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment