Commit dc531b64 authored by Max Kellermann's avatar Max Kellermann

db/update/InotifyQueue: migrate from TimeoutMonitor to TimerEvent

parent 91d4b5cf
...@@ -33,7 +33,7 @@ static constexpr std::chrono::steady_clock::duration INOTIFY_UPDATE_DELAY = ...@@ -33,7 +33,7 @@ static constexpr std::chrono::steady_clock::duration INOTIFY_UPDATE_DELAY =
std::chrono::seconds(5); std::chrono::seconds(5);
void void
InotifyQueue::OnTimeout() InotifyQueue::OnDelay()
{ {
unsigned id; unsigned id;
...@@ -43,7 +43,7 @@ InotifyQueue::OnTimeout() ...@@ -43,7 +43,7 @@ InotifyQueue::OnTimeout()
id = update.Enqueue(uri_utf8, false); id = update.Enqueue(uri_utf8, false);
if (id == 0) { if (id == 0) {
/* retry later */ /* retry later */
Schedule(INOTIFY_UPDATE_DELAY); delay_event.Schedule(INOTIFY_UPDATE_DELAY);
return; return;
} }
...@@ -69,7 +69,7 @@ path_in(const char *path, const char *possible_parent) noexcept ...@@ -69,7 +69,7 @@ path_in(const char *path, const char *possible_parent) noexcept
void void
InotifyQueue::Enqueue(const char *uri_utf8) 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;) { for (auto i = queue.begin(), end = queue.end(); i != end;) {
const char *current_uri = i->c_str(); const char *current_uri = i->c_str();
......
...@@ -20,27 +20,29 @@ ...@@ -20,27 +20,29 @@
#ifndef MPD_INOTIFY_QUEUE_HXX #ifndef MPD_INOTIFY_QUEUE_HXX
#define MPD_INOTIFY_QUEUE_HXX #define MPD_INOTIFY_QUEUE_HXX
#include "event/TimeoutMonitor.hxx" #include "event/TimerEvent.hxx"
#include "Compiler.h"
#include <list> #include <list>
#include <string> #include <string>
class UpdateService; class UpdateService;
class InotifyQueue final : private TimeoutMonitor { class InotifyQueue final {
UpdateService &update; UpdateService &update;
std::list<std::string> queue; std::list<std::string> queue;
TimerEvent delay_event;
public: public:
InotifyQueue(EventLoop &_loop, UpdateService &_update) InotifyQueue(EventLoop &_loop, UpdateService &_update)
:TimeoutMonitor(_loop), update(_update) {} :update(_update),
delay_event(_loop, BIND_THIS_METHOD(OnDelay)) {}
void Enqueue(const char *uri_utf8); void Enqueue(const char *uri_utf8);
private: private:
virtual void OnTimeout() override; void OnDelay();
}; };
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment