db/update/InotifyQueue: migrate from TimeoutMonitor to TimerEvent

This commit is contained in:
Max Kellermann 2017-08-29 16:38:50 +02:00
parent 91d4b5cfed
commit dc531b64ae
2 changed files with 10 additions and 8 deletions

View File

@ -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();

View File

@ -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 <list>
#include <string>
class UpdateService;
class InotifyQueue final : private TimeoutMonitor {
class InotifyQueue final {
UpdateService &update;
std::list<std::string> 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