events/MultiSocketMonitor: add method ForEachResult()

This commit is contained in:
Max Kellermann 2018-11-08 14:19:57 +01:00
parent 12308a0f55
commit ba5c856f15

View File

@ -194,6 +194,19 @@ public:
void ReplaceSocketList(pollfd *pfds, unsigned n) noexcept; void ReplaceSocketList(pollfd *pfds, unsigned n) noexcept;
#endif #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: protected:
/** /**
* Override this method and update the socket registrations. * Override this method and update the socket registrations.