events/MultiSocketMonitor: add method ForEachResult()

This commit is contained in:
Max Kellermann 2018-11-08 14:19:57 +01:00
parent 12308a0f55
commit ba5c856f15
1 changed files with 13 additions and 0 deletions

View File

@ -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.