Commit ba5c856f authored by Max Kellermann's avatar Max Kellermann

events/MultiSocketMonitor: add method ForEachResult()

parent 12308a0f
......@@ -194,6 +194,19 @@ public:
void ReplaceSocketList(pollfd *pfds, unsigned n) noexcept;
#endif
/**
* Invoke a function for each socket which has become ready.
*/
template<typename F>
void ForEachReturnedEvent(F &&f) noexcept {
for (auto &i : fds) {
if (i.GetReturnedEvents() != 0) {
f(i.GetSocket(), i.GetReturnedEvents());
i.ClearReturnedEvents();
}
}
}
protected:
/**
* Override this method and update the socket registrations.
......
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