event/WinSelect: merge duplicate code into ApplyReady()
This commit is contained in:
parent
b1e446a931
commit
9e97acc28d
@ -117,6 +117,14 @@ WinSelectBackend::Remove(SOCKET fd) noexcept
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
WinSelectBackend::ApplyReady(const SocketSet &src, unsigned events) noexcept
|
||||||
|
{
|
||||||
|
for (const auto i : src) {
|
||||||
|
items[i].events |= events;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
PollResultGeneric
|
PollResultGeneric
|
||||||
WinSelectBackend::ReadEvents(int timeout_ms) noexcept
|
WinSelectBackend::ReadEvents(int timeout_ms) noexcept
|
||||||
{
|
{
|
||||||
@ -148,14 +156,9 @@ WinSelectBackend::ReadEvents(int timeout_ms) noexcept
|
|||||||
if (ret == 0 || ret == SOCKET_ERROR)
|
if (ret == 0 || ret == SOCKET_ERROR)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
for (const auto i : read_set)
|
ApplyReady(read_set, WinSelectEvents::READ);
|
||||||
items[i].events |= WinSelectEvents::READ;
|
ApplyReady(write_set, WinSelectEvents::WRITE);
|
||||||
|
ApplyReady(except_set, WinSelectEvents::WRITE);
|
||||||
for (const auto i : write_set)
|
|
||||||
items[i].events |= WinSelectEvents::WRITE;
|
|
||||||
|
|
||||||
for (const auto i : except_set)
|
|
||||||
items[i].events |= WinSelectEvents::WRITE;
|
|
||||||
|
|
||||||
for (auto &i : items)
|
for (auto &i : items)
|
||||||
if (i.second.events != 0) {
|
if (i.second.events != 0) {
|
||||||
|
@ -119,6 +119,8 @@ private:
|
|||||||
int event_id) const noexcept;
|
int event_id) const noexcept;
|
||||||
void Modify(Item &item, SOCKET fd, unsigned events,
|
void Modify(Item &item, SOCKET fd, unsigned events,
|
||||||
int event_id) noexcept;
|
int event_id) noexcept;
|
||||||
|
|
||||||
|
void ApplyReady(const SocketSet &src, unsigned events) noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user