Added class JobResults.
This commit is contained in:
parent
9bf4c2c98f
commit
ea1149a971
9 changed files with 199 additions and 47 deletions
|
@ -28,6 +28,7 @@
|
|||
|
||||
|
||||
#include "crypto/cn/CryptoNight_test.h"
|
||||
#include "net/JobResults.h"
|
||||
#include "workers/CpuThreadLegacy.h"
|
||||
#include "workers/MultiWorker.h"
|
||||
#include "workers/Workers.h"
|
||||
|
@ -170,7 +171,7 @@ void xmrig::MultiWorker<N>::start()
|
|||
|
||||
for (size_t i = 0; i < N; ++i) {
|
||||
if (*reinterpret_cast<uint64_t*>(m_hash + (i * 32) + 24) < m_state.job.target()) {
|
||||
Workers::submit(JobResult(m_state.job.poolId(), m_state.job.id(), m_state.job.clientId(), *nonce(i), m_hash + (i * 32), m_state.job.diff(), m_state.job.algorithm()));
|
||||
JobResults::submit(JobResult(m_state.job.poolId(), m_state.job.id(), m_state.job.clientId(), *nonce(i), m_hash + (i * 32), m_state.job.diff(), m_state.job.algorithm()));
|
||||
}
|
||||
|
||||
*nonce(i) += 1;
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
#include "base/tools/Handle.h"
|
||||
#include "core/config/Config.h"
|
||||
#include "core/Controller.h"
|
||||
#include "interfaces/IJobResultListener.h"
|
||||
#include "interfaces/IThread.h"
|
||||
#include "Mem.h"
|
||||
#include "rapidjson/document.h"
|
||||
|
@ -45,15 +44,12 @@
|
|||
bool Workers::m_active = false;
|
||||
bool Workers::m_enabled = true;
|
||||
Hashrate *Workers::m_hashrate = nullptr;
|
||||
xmrig::IJobResultListener *Workers::m_listener = nullptr;
|
||||
xmrig::Job Workers::m_job;
|
||||
Workers::LaunchStatus Workers::m_status;
|
||||
std::atomic<int> Workers::m_paused;
|
||||
std::atomic<uint64_t> Workers::m_sequence;
|
||||
std::list<xmrig::JobResult> Workers::m_queue;
|
||||
std::vector<ThreadHandle*> Workers::m_workers;
|
||||
uint64_t Workers::m_ticks = 0;
|
||||
uv_async_t *Workers::m_async = nullptr;
|
||||
uv_mutex_t Workers::m_mutex;
|
||||
uv_rwlock_t Workers::m_rwlock;
|
||||
uv_timer_t *Workers::m_timer = nullptr;
|
||||
|
@ -199,9 +195,6 @@ void Workers::start(xmrig::Controller *controller)
|
|||
m_sequence = 1;
|
||||
m_paused = 1;
|
||||
|
||||
m_async = new uv_async_t;
|
||||
uv_async_init(uv_default_loop(), m_async, Workers::onResult);
|
||||
|
||||
m_timer = new uv_timer_t;
|
||||
uv_timer_init(uv_default_loop(), m_timer);
|
||||
uv_timer_start(m_timer, Workers::onTick, 500, 500);
|
||||
|
@ -221,7 +214,6 @@ void Workers::start(xmrig::Controller *controller)
|
|||
void Workers::stop()
|
||||
{
|
||||
xmrig::Handle::close(m_timer);
|
||||
xmrig::Handle::close(m_async);
|
||||
m_hashrate->stop();
|
||||
|
||||
m_paused = 0;
|
||||
|
@ -233,16 +225,6 @@ void Workers::stop()
|
|||
}
|
||||
|
||||
|
||||
void Workers::submit(const xmrig::JobResult &result)
|
||||
{
|
||||
uv_mutex_lock(&m_mutex);
|
||||
m_queue.push_back(result);
|
||||
uv_mutex_unlock(&m_mutex);
|
||||
|
||||
uv_async_send(m_async);
|
||||
}
|
||||
|
||||
|
||||
#ifdef XMRIG_FEATURE_API
|
||||
void Workers::threadsSummary(rapidjson::Document &doc)
|
||||
{
|
||||
|
@ -306,25 +288,6 @@ void Workers::onReady(void *arg)
|
|||
}
|
||||
|
||||
|
||||
void Workers::onResult(uv_async_t *)
|
||||
{
|
||||
std::list<xmrig::JobResult> results;
|
||||
|
||||
uv_mutex_lock(&m_mutex);
|
||||
while (!m_queue.empty()) {
|
||||
results.push_back(std::move(m_queue.front()));
|
||||
m_queue.pop_front();
|
||||
}
|
||||
uv_mutex_unlock(&m_mutex);
|
||||
|
||||
for (auto result : results) {
|
||||
m_listener->onJobResult(result);
|
||||
}
|
||||
|
||||
results.clear();
|
||||
}
|
||||
|
||||
|
||||
void Workers::onTick(uv_timer_t *)
|
||||
{
|
||||
for (ThreadHandle *handle : m_workers) {
|
||||
|
|
|
@ -47,7 +47,6 @@ class ThreadHandle;
|
|||
|
||||
namespace xmrig {
|
||||
class Controller;
|
||||
class IJobResultListener;
|
||||
}
|
||||
|
||||
|
||||
|
@ -62,7 +61,6 @@ public:
|
|||
static void setJob(const xmrig::Job &job, bool donate);
|
||||
static void start(xmrig::Controller *controller);
|
||||
static void stop();
|
||||
static void submit(const xmrig::JobResult &result);
|
||||
|
||||
static inline bool isEnabled() { return m_enabled; }
|
||||
static inline bool isOutdated(uint64_t sequence) { return m_sequence.load(std::memory_order_relaxed) != sequence; }
|
||||
|
@ -70,7 +68,6 @@ public:
|
|||
static inline Hashrate *hashrate() { return m_hashrate; }
|
||||
static inline uint64_t sequence() { return m_sequence.load(std::memory_order_relaxed); }
|
||||
static inline void pause() { m_active = false; m_paused = 1; m_sequence++; }
|
||||
static inline void setListener(xmrig::IJobResultListener *listener) { m_listener = listener; }
|
||||
|
||||
# ifdef XMRIG_FEATURE_API
|
||||
static void threadsSummary(rapidjson::Document &doc);
|
||||
|
@ -83,7 +80,6 @@ public:
|
|||
|
||||
private:
|
||||
static void onReady(void *arg);
|
||||
static void onResult(uv_async_t *handle);
|
||||
static void onTick(uv_timer_t *handle);
|
||||
static void start(IWorker *worker);
|
||||
|
||||
|
@ -109,15 +105,12 @@ private:
|
|||
static bool m_active;
|
||||
static bool m_enabled;
|
||||
static Hashrate *m_hashrate;
|
||||
static xmrig::IJobResultListener *m_listener;
|
||||
static xmrig::Job m_job;
|
||||
static LaunchStatus m_status;
|
||||
static std::atomic<int> m_paused;
|
||||
static std::atomic<uint64_t> m_sequence;
|
||||
static std::list<xmrig::JobResult> m_queue;
|
||||
static std::vector<ThreadHandle*> m_workers;
|
||||
static uint64_t m_ticks;
|
||||
static uv_async_t *m_async;
|
||||
static uv_mutex_t m_mutex;
|
||||
static uv_rwlock_t m_rwlock;
|
||||
static uv_timer_t *m_timer;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue