Commit 598bb93c authored by Max Kellermann's avatar Max Kellermann

StateFile: migrate from TimeoutMonitor to TimerEvent

parent dc531b64
...@@ -42,9 +42,9 @@ constexpr std::chrono::steady_clock::duration StateFile::DEFAULT_INTERVAL; ...@@ -42,9 +42,9 @@ constexpr std::chrono::steady_clock::duration StateFile::DEFAULT_INTERVAL;
StateFile::StateFile(AllocatedPath &&_path, StateFile::StateFile(AllocatedPath &&_path,
std::chrono::steady_clock::duration _interval, std::chrono::steady_clock::duration _interval,
Partition &_partition, EventLoop &_loop) Partition &_partition, EventLoop &_loop)
:TimeoutMonitor(_loop), :path(std::move(_path)), path_utf8(path.ToUTF8()),
path(std::move(_path)), path_utf8(path.ToUTF8()),
interval(_interval), interval(_interval),
timer_event(_loop, BIND_THIS_METHOD(OnTimeout)),
partition(_partition) partition(_partition)
{ {
} }
...@@ -137,8 +137,8 @@ try { ...@@ -137,8 +137,8 @@ try {
void void
StateFile::CheckModified() StateFile::CheckModified()
{ {
if (!IsActive() && IsModified()) if (!timer_event.IsActive() && IsModified())
Schedule(interval); timer_event.Schedule(interval);
} }
void void
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#ifndef MPD_STATE_FILE_HXX #ifndef MPD_STATE_FILE_HXX
#define MPD_STATE_FILE_HXX #define MPD_STATE_FILE_HXX
#include "event/TimeoutMonitor.hxx" #include "event/TimerEvent.hxx"
#include "fs/AllocatedPath.hxx" #include "fs/AllocatedPath.hxx"
#include "Compiler.h" #include "Compiler.h"
...@@ -31,11 +31,12 @@ struct Partition; ...@@ -31,11 +31,12 @@ struct Partition;
class OutputStream; class OutputStream;
class BufferedOutputStream; class BufferedOutputStream;
class StateFile final : private TimeoutMonitor { class StateFile final {
const AllocatedPath path; const AllocatedPath path;
const std::string path_utf8; const std::string path_utf8;
const std::chrono::steady_clock::duration interval; const std::chrono::steady_clock::duration interval;
TimerEvent timer_event;
Partition &partition; Partition &partition;
...@@ -76,8 +77,8 @@ private: ...@@ -76,8 +77,8 @@ private:
gcc_pure gcc_pure
bool IsModified() const noexcept; bool IsModified() const noexcept;
/* virtual methods from TimeoutMonitor */ /* callback for #timer_event */
void OnTimeout() override; void OnTimeout();
}; };
#endif /* STATE_FILE_H */ #endif /* STATE_FILE_H */
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