Rewritten watch feature.

This commit is contained in:
XMRig 2019-02-15 04:59:20 +07:00
parent b368ffacdb
commit 0450c31449
19 changed files with 419 additions and 111 deletions

View file

@ -21,6 +21,10 @@ set(HEADERS
src/api/NetworkState.h
src/App.h
src/base/io/Json.h
src/base/io/Watcher.h
src/base/kernel/interfaces/IConfigListener.h
src/base/kernel/interfaces/IWatcherListener.h
src/base/tools/Handle.h
src/base/tools/String.h
src/common/config/CommonConfig.h
src/common/config/ConfigLoader.h
@ -38,7 +42,6 @@ set(HEADERS
src/common/interfaces/ILogBackend.h
src/common/interfaces/IStrategy.h
src/common/interfaces/IStrategyListener.h
src/common/interfaces/IWatcherListener.h
src/common/log/BasicLog.h
src/common/log/ConsoleLog.h
src/common/log/FileLog.h
@ -100,6 +103,8 @@ set(SOURCES
src/api/NetworkState.cpp
src/App.cpp
src/base/io/Json.cpp
src/base/io/Watcher.cpp
src/base/tools/Handle.cpp
src/base/tools/String.cpp
src/common/config/CommonConfig.cpp
src/common/config/ConfigLoader.cpp

94
src/base/io/Watcher.cpp Normal file
View file

@ -0,0 +1,94 @@
/* XMRig
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <uv.h>
#include "base/kernel/interfaces/IWatcherListener.h"
#include "base/io/Watcher.h"
#include "base/tools/Handle.h"
xmrig::Watcher::Watcher(const String &path, IWatcherListener *listener) :
m_listener(listener),
m_path(path)
{
m_fsEvent = new uv_fs_event_t;
uv_fs_event_init(uv_default_loop(), m_fsEvent);
m_timer = new uv_timer_t;
uv_timer_init(uv_default_loop(), m_timer);
m_fsEvent->data = m_timer->data = this;
start();
}
xmrig::Watcher::~Watcher()
{
Handle::close(m_timer);
Handle::close(m_fsEvent);
}
void xmrig::Watcher::onTimer(uv_timer_t *handle)
{
static_cast<Watcher *>(handle->data)->reload();
}
void xmrig::Watcher::onFsEvent(uv_fs_event_t *handle, const char *filename, int, int)
{
if (!filename) {
return;
}
static_cast<Watcher *>(handle->data)->queueUpdate();
}
void xmrig::Watcher::queueUpdate()
{
uv_timer_stop(m_timer);
uv_timer_start(m_timer, xmrig::Watcher::onTimer, kDelay, 0);
}
void xmrig::Watcher::reload()
{
m_listener->onFileChanged(m_path);
# ifndef _WIN32
uv_fs_event_stop(&m_fsEvent);
start();
# endif
}
void xmrig::Watcher::start()
{
uv_fs_event_start(m_fsEvent, xmrig::Watcher::onFsEvent, m_path, 0);
}

67
src/base/io/Watcher.h Normal file
View file

@ -0,0 +1,67 @@
/* XMRig
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef XMRIG_WATCHER_H
#define XMRIG_WATCHER_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 Watcher
{
public:
Watcher(const String &path, IWatcherListener *listener);
~Watcher();
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();
void start();
IWatcherListener *m_listener;
String m_path;
uv_fs_event_t *m_fsEvent;
uv_timer_t *m_timer;
};
} /* namespace xmrig */
#endif /* XMRIG_WATCHER_H */

View file

@ -0,0 +1,47 @@
/* XMRig
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef XMRIG_ICONFIGLISTENER_H
#define XMRIG_ICONFIGLISTENER_H
namespace xmrig {
class IConfig;
class IConfigListener
{
public:
virtual ~IConfigListener() = default;
virtual void onNewConfig(IConfig *config) = 0;
};
} /* namespace xmrig */
#endif // XMRIG_ICONFIGLISTENER_H

View file

@ -5,7 +5,8 @@
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -21,26 +22,26 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __IWATCHERLISTENER_H__
#define __IWATCHERLISTENER_H__
#ifndef XMRIG_IWATCHERLISTENER_H
#define XMRIG_IWATCHERLISTENER_H
namespace xmrig {
class IConfig;
class String;
class IWatcherListener
{
public:
virtual ~IWatcherListener() {}
virtual ~IWatcherListener() = default;
virtual void onNewConfig(IConfig *config) = 0;
virtual void onFileChanged(const String &fileName) = 0;
};
} /* namespace xmrig */
#endif // __IWATCHERLISTENER_H__
#endif // XMRIG_IWATCHERLISTENER_H

79
src/base/tools/Handle.cpp Normal file
View file

@ -0,0 +1,79 @@
/* XMRig
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <uv.h>
#include "base/tools/Handle.h"
void xmrig::Handle::close(uv_fs_event_t *handle)
{
if (handle) {
uv_fs_event_stop(handle);
close(reinterpret_cast<uv_handle_t *>(handle));
}
}
void xmrig::Handle::close(uv_getaddrinfo_t *handle)
{
if (handle) {
uv_cancel(reinterpret_cast<uv_req_t *>(handle));
close(reinterpret_cast<uv_handle_t *>(handle));
}
}
void xmrig::Handle::close(uv_handle_t *handle)
{
uv_close(handle, [](uv_handle_t *handle) { delete handle; });
}
void xmrig::Handle::close(uv_signal_t *handle)
{
if (handle) {
uv_signal_stop(handle);
close(reinterpret_cast<uv_handle_t *>(handle));
}
}
void xmrig::Handle::close(uv_tcp_t *handle)
{
if (handle) {
close(reinterpret_cast<uv_handle_t *>(handle));
}
}
void xmrig::Handle::close(uv_timer_s *handle)
{
if (handle) {
uv_timer_stop(handle);
close(reinterpret_cast<uv_handle_t *>(handle));
}
}

55
src/base/tools/Handle.h Normal file
View file

@ -0,0 +1,55 @@
/* XMRig
* Copyright 2010 Jeff Garzik <jgarzik@pobox.com>
* Copyright 2012-2014 pooler <pooler@litecoinpool.org>
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef XMRIG_HANDLE_H
#define XMRIG_HANDLE_H
typedef struct uv_fs_event_s uv_fs_event_t;
typedef struct uv_getaddrinfo_s uv_getaddrinfo_t;
typedef struct uv_handle_s uv_handle_t;
typedef struct uv_signal_s uv_signal_t;
typedef struct uv_tcp_s uv_tcp_t;
typedef struct uv_timer_s uv_timer_t;
namespace xmrig {
class Handle
{
public:
static void close(uv_fs_event_t *handle);
static void close(uv_getaddrinfo_t *handle);
static void close(uv_handle_t *handle);
static void close(uv_signal_t *handle);
static void close(uv_tcp_t *handle);
static void close(uv_timer_t *handle);
};
} /* namespace xmrig */
#endif /* XMRIG_HANDLE_H */

View file

@ -65,7 +65,7 @@ public:
inline bool isWatch() const override { return m_watch && !m_fileName.isNull(); }
inline const Algorithm &algorithm() const override { return m_algorithm; }
inline const char *fileName() const override { return m_fileName.data(); }
inline const String &fileName() const override { return m_fileName; }
bool save() override;

View file

@ -39,23 +39,22 @@
#include "base/io/Json.h"
#include "base/kernel/interfaces/IConfigListener.h"
#include "common/config/ConfigLoader.h"
#include "common/config/ConfigWatcher.h"
#include "common/interfaces/IConfig.h"
#include "common/interfaces/IWatcherListener.h"
#include "common/net/Pool.h"
#include "common/Platform.h"
#include "core/ConfigCreator.h"
#include "core/ConfigLoader_platform.h"
#include "rapidjson/document.h"
#include "rapidjson/error/en.h"
#include "rapidjson/filereadstream.h"
bool xmrig::ConfigLoader::m_done = false;
xmrig::ConfigWatcher *xmrig::ConfigLoader::m_watcher = nullptr;
xmrig::IConfigCreator *xmrig::ConfigLoader::m_creator = nullptr;
xmrig::IWatcherListener *xmrig::ConfigLoader::m_listener = nullptr;
xmrig::IConfigListener *xmrig::ConfigLoader::m_listener = nullptr;
#ifndef ARRAY_SIZE
@ -78,8 +77,9 @@ bool xmrig::ConfigLoader::loadFromFile(xmrig::IConfig *config, const char *fileN
bool xmrig::ConfigLoader::loadFromJSON(xmrig::IConfig *config, const char *json)
{
rapidjson::Document doc;
doc.Parse(json);
using namespace rapidjson;
Document doc;
doc.Parse<kParseCommentsFlag | kParseTrailingCommasFlag>(json);
if (doc.HasParseError() || !doc.IsObject()) {
return false;
@ -144,7 +144,7 @@ bool xmrig::ConfigLoader::reload(xmrig::IConfig *oldConfig, const char *json)
}
xmrig::IConfig *xmrig::ConfigLoader::load(int argc, char **argv, IConfigCreator *creator, IWatcherListener *listener)
xmrig::IConfig *xmrig::ConfigLoader::load(int argc, char **argv, IConfigCreator *creator, IConfigListener *listener)
{
m_creator = creator;
m_listener = listener;

View file

@ -40,7 +40,7 @@ namespace xmrig {
class ConfigWatcher;
class IConfigCreator;
class IWatcherListener;
class IConfigListener;
class IConfig;
@ -51,7 +51,7 @@ public:
static bool loadFromJSON(IConfig *config, const char *json);
static bool loadFromJSON(IConfig *config, const rapidjson::Document &doc);
static bool reload(IConfig *oldConfig, const char *json);
static IConfig *load(int argc, char **argv, IConfigCreator *creator, IWatcherListener *listener);
static IConfig *load(int argc, char **argv, IConfigCreator *creator, IConfigListener *listener);
static void release();
static inline bool isDone() { return m_done; }
@ -66,7 +66,7 @@ private:
static bool m_done;
static ConfigWatcher *m_watcher;
static IConfigCreator *m_creator;
static IWatcherListener *m_listener;
static IConfigListener *m_listener;
};

View file

@ -5,7 +5,8 @@
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -22,66 +23,35 @@
*/
#include <stdio.h>
#include "base/io/Watcher.h"
#include "base/kernel/interfaces/IConfigListener.h"
#include "common/config/ConfigLoader.h"
#include "common/config/ConfigWatcher.h"
#include "common/interfaces/IWatcherListener.h"
#include "common/log/Log.h"
#include "core/ConfigCreator.h"
xmrig::ConfigWatcher::ConfigWatcher(const char *path, IConfigCreator *creator, IWatcherListener *listener) :
xmrig::ConfigWatcher::ConfigWatcher(const String &path, IConfigCreator *creator, IConfigListener *listener) :
m_creator(creator),
m_listener(listener),
m_path(path)
m_listener(listener)
{
uv_fs_event_init(uv_default_loop(), &m_fsEvent);
uv_timer_init(uv_default_loop(), &m_timer);
m_fsEvent.data = m_timer.data = this;
start();
m_watcher = new Watcher(path, this);
}
xmrig::ConfigWatcher::~ConfigWatcher()
{
uv_timer_stop(&m_timer);
uv_fs_event_stop(&m_fsEvent);
delete m_watcher;
}
void xmrig::ConfigWatcher::onTimer(uv_timer_t* handle)
void xmrig::ConfigWatcher::onFileChanged(const String &fileName)
{
static_cast<xmrig::ConfigWatcher *>(handle->data)->reload();
}
void xmrig::ConfigWatcher::onFsEvent(uv_fs_event_t* handle, const char *filename, int events, int status)
{
if (!filename) {
return;
}
static_cast<xmrig::ConfigWatcher *>(handle->data)->queueUpdate();
}
void xmrig::ConfigWatcher::queueUpdate()
{
uv_timer_stop(&m_timer);
uv_timer_start(&m_timer, xmrig::ConfigWatcher::onTimer, kDelay, 0);
}
void xmrig::ConfigWatcher::reload()
{
LOG_WARN("\"%s\" was changed, reloading configuration", m_path.data());
LOG_WARN("\"%s\" was changed, reloading configuration", fileName.data());
IConfig *config = m_creator->create();
ConfigLoader::loadFromFile(config, m_path.data());
ConfigLoader::loadFromFile(config, fileName);
if (!config->finalize()) {
LOG_ERR("reloading failed");
@ -91,15 +61,4 @@ void xmrig::ConfigWatcher::reload()
}
m_listener->onNewConfig(config);
# ifndef _WIN32
uv_fs_event_stop(&m_fsEvent);
start();
# endif
}
void xmrig::ConfigWatcher::start()
{
uv_fs_event_start(&m_fsEvent, xmrig::ConfigWatcher::onFsEvent, m_path.data(), 0);
}

View file

@ -5,7 +5,8 @@
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -21,15 +22,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __CONFIGWATCHER_H__
#define __CONFIGWATCHER_H__
#ifndef XMRIG_CONFIGWATCHER_H
#define XMRIG_CONFIGWATCHER_H
#include <stdint.h>
#include <uv.h>
#include "common/utils/c_str.h"
#include "base/kernel/interfaces/IWatcherListener.h"
#include "base/tools/String.h"
#include "rapidjson/fwd.h"
@ -40,29 +38,23 @@ namespace xmrig {
class IConfigCreator;
class IWatcherListener;
class IConfigListener;
class Watcher;
class ConfigWatcher
class ConfigWatcher : public IWatcherListener
{
public:
ConfigWatcher(const char *path, IConfigCreator *creator, IWatcherListener *listener);
~ConfigWatcher();
ConfigWatcher(const String &path, IConfigCreator *creator, IConfigListener *listener);
~ConfigWatcher() override;
protected:
void onFileChanged(const String &fileName) override;
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();
void start();
IConfigCreator *m_creator;
IWatcherListener *m_listener;
uv_fs_event_t m_fsEvent;
uv_timer_t m_timer;
xmrig::c_str m_path;
IConfigListener *m_listener;
Watcher *m_watcher;
};

View file

@ -33,6 +33,9 @@
namespace xmrig {
class String;
class IConfig
{
public:
@ -136,7 +139,7 @@ public:
virtual bool parseUint64(int key, uint64_t arg) = 0;
virtual bool save() = 0;
virtual const Algorithm &algorithm() const = 0;
virtual const char *fileName() const = 0;
virtual const String &fileName() const = 0;
virtual void getJSON(rapidjson::Document &doc) const = 0;
virtual void parseJSON(const rapidjson::Document &doc) = 0;
virtual void setFileName(const char *fileName) = 0;

View file

@ -4,7 +4,9 @@
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2016-2018 XMRig <support@xmrig.com>
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -20,8 +22,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __ICONFIGCREATOR_H__
#define __ICONFIGCREATOR_H__
#ifndef XMRIG_ICONFIGCREATOR_H
#define XMRIG_ICONFIGCREATOR_H
namespace xmrig {
@ -33,7 +35,7 @@ class IConfig;
class IConfigCreator
{
public:
virtual ~IConfigCreator() {}
virtual ~IConfigCreator() = default;
virtual IConfig *create() const = 0;
};
@ -42,4 +44,4 @@ public:
} /* namespace xmrig */
#endif // __ICONFIGCREATOR_H__
#endif // XMRIG_ICONFIGCREATOR_H

View file

@ -139,7 +139,7 @@ void xmrig::Config::getJSON(rapidjson::Document &doc) const
}
xmrig::Config *xmrig::Config::load(int argc, char **argv, IWatcherListener *listener)
xmrig::Config *xmrig::Config::load(int argc, char **argv, IConfigListener *listener)
{
return static_cast<Config*>(ConfigLoader::load(argc, argv, new ConfigCreator(), listener));
}

View file

@ -44,7 +44,7 @@ namespace xmrig {
class ConfigLoader;
class IThread;
class IWatcherListener;
class IConfigListener;
/**
@ -85,7 +85,7 @@ public:
inline int64_t affinity() const { return m_threads.mask; }
inline ThreadsMode threadsMode() const { return m_threads.mode; }
static Config *load(int argc, char **argv, IWatcherListener *listener);
static Config *load(int argc, char **argv, IConfigListener *listener);
protected:
bool finalize() override;

View file

@ -5,8 +5,8 @@
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -122,6 +122,7 @@ static struct option const options[] = {
{ "max-cpu-usage", 1, nullptr, xmrig::IConfig::MaxCPUUsageKey },
{ "nicehash", 0, nullptr, xmrig::IConfig::NicehashKey },
{ "no-color", 0, nullptr, xmrig::IConfig::ColorKey },
{ "no-watch", 0, nullptr, xmrig::IConfig::WatchKey },
{ "no-huge-pages", 0, nullptr, xmrig::IConfig::HugePagesKey },
{ "variant", 1, nullptr, xmrig::IConfig::VariantKey },
{ "pass", 1, nullptr, xmrig::IConfig::PasswordKey },
@ -163,6 +164,7 @@ static struct option const config_options[] = {
{ "syslog", 0, nullptr, xmrig::IConfig::SyslogKey },
{ "threads", 1, nullptr, xmrig::IConfig::ThreadsKey },
{ "user-agent", 1, nullptr, xmrig::IConfig::UserAgentKey },
{ "watch", 0, nullptr, xmrig::IConfig::WatchKey },
{ "hw-aes", 0, nullptr, xmrig::IConfig::HardwareAESKey },
{ "asm", 1, nullptr, xmrig::IConfig::AssemblyKey },
{ "autosave", 0, nullptr, xmrig::IConfig::AutoSaveKey },

View file

@ -5,7 +5,8 @@
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View file

@ -5,7 +5,8 @@
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <jayddee246@gmail.com>
* Copyright 2017-2018 XMR-Stak <https://github.com/fireice-uk>, <https://github.com/psychocrypt>
* Copyright 2016-2018 XMRig <https://github.com/xmrig>, <support@xmrig.com>
* Copyright 2018-2019 SChernykh <https://github.com/SChernykh>
* Copyright 2016-2019 XMRig <https://github.com/xmrig>, <support@xmrig.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -25,7 +26,7 @@
#define XMRIG_CONTROLLER_H
#include "common/interfaces/IWatcherListener.h"
#include "base/kernel/interfaces/IConfigListener.h"
class Network;
@ -40,11 +41,11 @@ class ControllerPrivate;
class IControllerListener;
class Controller : public IWatcherListener
class Controller : public IConfigListener
{
public:
Controller();
~Controller();
~Controller() override;
bool isDone() const;
bool isReady() const;