summaryrefslogtreecommitdiff
path: root/src/zeroconf
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2017-08-29 16:17:38 +0200
committerMax Kellermann <max@musicpd.org>2017-08-29 16:28:27 +0200
commit11f36c0bd60f0d852e11c80fa42e0ce564985039 (patch)
treed7ccad3bb279598a24a1c87abfb4338c32ac1df2 /src/zeroconf
parentfd520eeed2b7381130a919bcab08d340ab077a27 (diff)
zeroconf/AvahiPoll: migrate from TimeoutMonitor to TimerEvent
Diffstat (limited to 'src/zeroconf')
-rw-r--r--src/zeroconf/AvahiPoll.cxx19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/zeroconf/AvahiPoll.cxx b/src/zeroconf/AvahiPoll.cxx
index 4f272b11d..6359e5843 100644
--- a/src/zeroconf/AvahiPoll.cxx
+++ b/src/zeroconf/AvahiPoll.cxx
@@ -20,7 +20,7 @@
#include "config.h"
#include "AvahiPoll.hxx"
#include "event/SocketMonitor.hxx"
-#include "event/TimeoutMonitor.hxx"
+#include "event/TimerEvent.hxx"
static unsigned
FromAvahiWatchEvent(AvahiWatchEvent e)
@@ -84,8 +84,9 @@ TimevalToChrono(const timeval &tv)
return std::chrono::seconds(tv.tv_sec) + std::chrono::microseconds(tv.tv_usec);
}
-struct AvahiTimeout final : private TimeoutMonitor {
-private:
+struct AvahiTimeout final {
+ TimerEvent timer;
+
const AvahiTimeoutCallback callback;
void *const userdata;
@@ -93,25 +94,25 @@ public:
AvahiTimeout(const struct timeval *tv,
AvahiTimeoutCallback _callback, void *_userdata,
EventLoop &_loop)
- :TimeoutMonitor(_loop),
+ :timer(_loop, BIND_THIS_METHOD(OnTimeout)),
callback(_callback), userdata(_userdata) {
if (tv != nullptr)
- Schedule(TimevalToChrono(*tv));
+ timer.Schedule(TimevalToChrono(*tv));
}
static void TimeoutUpdate(AvahiTimeout *t, const struct timeval *tv) {
if (tv != nullptr)
- t->Schedule(TimevalToChrono(*tv));
+ t->timer.Schedule(TimevalToChrono(*tv));
else
- t->Cancel();
+ t->timer.Cancel();
}
static void TimeoutFree(AvahiTimeout *t) {
delete t;
}
-protected:
- virtual void OnTimeout() {
+private:
+ void OnTimeout() {
callback(this, userdata);
}
};