From dc531b64ae3a2df5a796a1e6f9b1de1b528be2a0 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 29 Aug 2017 16:38:50 +0200 Subject: [PATCH] db/update/InotifyQueue: migrate from TimeoutMonitor to TimerEvent --- src/db/update/InotifyQueue.cxx | 6 +++--- src/db/update/InotifyQueue.hxx | 12 +++++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/db/update/InotifyQueue.cxx b/src/db/update/InotifyQueue.cxx index d83d26612..8747ffd66 100644 --- a/src/db/update/InotifyQueue.cxx +++ b/src/db/update/InotifyQueue.cxx @@ -33,7 +33,7 @@ static constexpr std::chrono::steady_clock::duration INOTIFY_UPDATE_DELAY = std::chrono::seconds(5); void -InotifyQueue::OnTimeout() +InotifyQueue::OnDelay() { unsigned id; @@ -43,7 +43,7 @@ InotifyQueue::OnTimeout() id = update.Enqueue(uri_utf8, false); if (id == 0) { /* retry later */ - Schedule(INOTIFY_UPDATE_DELAY); + delay_event.Schedule(INOTIFY_UPDATE_DELAY); return; } @@ -69,7 +69,7 @@ path_in(const char *path, const char *possible_parent) noexcept void InotifyQueue::Enqueue(const char *uri_utf8) { - Schedule(INOTIFY_UPDATE_DELAY); + delay_event.Schedule(INOTIFY_UPDATE_DELAY); for (auto i = queue.begin(), end = queue.end(); i != end;) { const char *current_uri = i->c_str(); diff --git a/src/db/update/InotifyQueue.hxx b/src/db/update/InotifyQueue.hxx index 47c960ded..8a60def8b 100644 --- a/src/db/update/InotifyQueue.hxx +++ b/src/db/update/InotifyQueue.hxx @@ -20,27 +20,29 @@ #ifndef MPD_INOTIFY_QUEUE_HXX #define MPD_INOTIFY_QUEUE_HXX -#include "event/TimeoutMonitor.hxx" -#include "Compiler.h" +#include "event/TimerEvent.hxx" #include #include class UpdateService; -class InotifyQueue final : private TimeoutMonitor { +class InotifyQueue final { UpdateService &update; std::list queue; + TimerEvent delay_event; + public: InotifyQueue(EventLoop &_loop, UpdateService &_update) - :TimeoutMonitor(_loop), update(_update) {} + :update(_update), + delay_event(_loop, BIND_THIS_METHOD(OnDelay)) {} void Enqueue(const char *uri_utf8); private: - virtual void OnTimeout() override; + void OnDelay(); }; #endif