summaryrefslogtreecommitdiff
path: root/src/event
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2018-11-08 14:19:57 +0100
committerMax Kellermann <max@musicpd.org>2018-11-11 12:37:28 +0100
commitba5c856f154fcfbbb6643e32e020c1c3bc2e8feb (patch)
treeb40e674c4e09f04542500a4f625047215af1bbd4 /src/event
parent12308a0f551b7928da02c3d7bd0681fa9e4243e7 (diff)
events/MultiSocketMonitor: add method ForEachResult()
Diffstat (limited to 'src/event')
-rw-r--r--src/event/MultiSocketMonitor.hxx13
1 files changed, 13 insertions, 0 deletions
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<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.