diff --git a/src/event/MultiSocketMonitor.hxx b/src/event/MultiSocketMonitor.hxx index 3d063e6c3..37c50eb75 100644 --- a/src/event/MultiSocketMonitor.hxx +++ b/src/event/MultiSocketMonitor.hxx @@ -194,6 +194,19 @@ public: void ReplaceSocketList(pollfd *pfds, unsigned n) noexcept; #endif + /** + * Invoke a function for each socket which has become ready. + */ + template + 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.