Add class Timer.
This commit is contained in:
parent
bbf0d11a51
commit
9a6a5a94b5
13 changed files with 271 additions and 73 deletions
|
@ -26,30 +26,33 @@
|
|||
#define XMRIG_WATCHER_H
|
||||
|
||||
|
||||
#include "base/kernel/interfaces/ITimerListener.h"
|
||||
#include "base/tools/String.h"
|
||||
|
||||
|
||||
typedef struct uv_fs_event_s uv_fs_event_t;
|
||||
typedef struct uv_timer_s uv_timer_t;
|
||||
|
||||
|
||||
namespace xmrig {
|
||||
|
||||
|
||||
class IWatcherListener;
|
||||
class Timer;
|
||||
|
||||
|
||||
class Watcher
|
||||
class Watcher : public ITimerListener
|
||||
{
|
||||
public:
|
||||
Watcher(const String &path, IWatcherListener *listener);
|
||||
~Watcher();
|
||||
~Watcher() override;
|
||||
|
||||
protected:
|
||||
inline void onTimer(const Timer *) override { reload(); }
|
||||
|
||||
private:
|
||||
constexpr static int kDelay = 500;
|
||||
|
||||
static void onFsEvent(uv_fs_event_t *handle, const char *filename, int events, int status);
|
||||
static void onTimer(uv_timer_t *handle);
|
||||
|
||||
void queueUpdate();
|
||||
void reload();
|
||||
|
@ -57,11 +60,12 @@ private:
|
|||
|
||||
IWatcherListener *m_listener;
|
||||
String m_path;
|
||||
Timer *m_timer;
|
||||
uv_fs_event_t *m_fsEvent;
|
||||
uv_timer_t *m_timer;
|
||||
};
|
||||
|
||||
|
||||
} /* namespace xmrig */
|
||||
|
||||
|
||||
#endif /* XMRIG_WATCHER_H */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue