Cleanup
This commit is contained in:
parent
c8ee6f7db8
commit
daf08fcf9a
8 changed files with 86 additions and 100 deletions
|
@ -1,13 +1,6 @@
|
|||
/* 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 Lee Clagett <https://github.com/vtnerd>
|
||||
* Copyright 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright 2016-2020 XMRig <https://github.com/xmrig>, <support@xmrig.com>
|
||||
* Copyright (c) 2018-2020 SChernykh <https://github.com/SChernykh>
|
||||
* Copyright (c) 2016-2020 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
|
||||
|
@ -24,16 +17,13 @@
|
|||
*/
|
||||
|
||||
|
||||
#include "backend/common/Workers.h"
|
||||
#include "backend/common/Hashrate.h"
|
||||
#include "backend/common/interfaces/IBackend.h"
|
||||
#include "backend/common/Workers.h"
|
||||
#include "backend/cpu/CpuWorker.h"
|
||||
#include "base/io/log/Log.h"
|
||||
#include "base/io/log/Tags.h"
|
||||
#include "base/net/stratum/Pool.h"
|
||||
#include "base/tools/Chrono.h"
|
||||
#include "base/tools/Object.h"
|
||||
#include "core/Miner.h"
|
||||
|
||||
|
||||
#ifdef XMRIG_FEATURE_OPENCL
|
||||
|
@ -59,7 +49,6 @@ class WorkersPrivate
|
|||
public:
|
||||
XMRIG_DISABLE_COPY_MOVE(WorkersPrivate)
|
||||
|
||||
|
||||
WorkersPrivate() = default;
|
||||
~WorkersPrivate() = default;
|
||||
|
||||
|
@ -69,6 +58,20 @@ public:
|
|||
};
|
||||
|
||||
|
||||
template<class T>
|
||||
inline static void getHashrateData(IWorker *worker, uint64_t &hashCount, uint64_t &timeStamp)
|
||||
{
|
||||
worker->getHashrateData(hashCount, timeStamp);
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
inline void getHashrateData<xmrig::CpuLaunchData>(IWorker *worker, uint64_t &hashCount, uint64_t &)
|
||||
{
|
||||
hashCount = worker->rawHashes();
|
||||
}
|
||||
|
||||
|
||||
} // namespace xmrig
|
||||
|
||||
|
||||
|
@ -87,20 +90,6 @@ xmrig::Workers<T>::~Workers()
|
|||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
static void getHashrateData(xmrig::IWorker* worker, uint64_t& hashCount, uint64_t& timeStamp)
|
||||
{
|
||||
worker->getHashrateData(hashCount, timeStamp);
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
void getHashrateData<xmrig::CpuLaunchData>(xmrig::IWorker* worker, uint64_t& hashCount, uint64_t&)
|
||||
{
|
||||
hashCount = worker->rawHashes();
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
bool xmrig::Workers<T>::tick(uint64_t)
|
||||
{
|
||||
|
@ -132,12 +121,10 @@ bool xmrig::Workers<T>::tick(uint64_t)
|
|||
}
|
||||
|
||||
# ifdef XMRIG_FEATURE_BENCHMARK
|
||||
if (d_ptr->benchmark && d_ptr->benchmark->finish(totalHashCount)) {
|
||||
return false;
|
||||
}
|
||||
# endif
|
||||
|
||||
return !d_ptr->benchmark || !d_ptr->benchmark->finish(totalHashCount);
|
||||
# else
|
||||
return true;
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -158,14 +145,19 @@ void xmrig::Workers<T>::setBackend(IBackend *backend)
|
|||
template<class T>
|
||||
void xmrig::Workers<T>::stop()
|
||||
{
|
||||
# ifdef XMRIG_MINER_PROJECT
|
||||
Nonce::stop(T::backend());
|
||||
# endif
|
||||
|
||||
for (Thread<T> *worker : m_workers) {
|
||||
delete worker;
|
||||
}
|
||||
|
||||
m_workers.clear();
|
||||
|
||||
# ifdef XMRIG_MINER_PROJECT
|
||||
Nonce::touch(T::backend());
|
||||
# endif
|
||||
|
||||
d_ptr->hashrate.reset();
|
||||
}
|
||||
|
@ -226,7 +218,10 @@ void xmrig::Workers<T>::start(const std::vector<T> &data, bool sleep)
|
|||
}
|
||||
|
||||
d_ptr->hashrate = std::make_shared<Hashrate>(m_workers.size());
|
||||
|
||||
# ifdef XMRIG_MINER_PROJECT
|
||||
Nonce::touch(T::backend());
|
||||
# endif
|
||||
|
||||
for (auto worker : m_workers) {
|
||||
worker->start(Workers<T>::onReady);
|
||||
|
@ -247,6 +242,7 @@ namespace xmrig {
|
|||
template<>
|
||||
xmrig::IWorker *xmrig::Workers<CpuLaunchData>::create(Thread<CpuLaunchData> *handle)
|
||||
{
|
||||
# ifdef XMRIG_MINER_PROJECT
|
||||
switch (handle->config().intensity) {
|
||||
case 1:
|
||||
return new CpuWorker<1>(handle->id(), handle->config());
|
||||
|
@ -265,6 +261,11 @@ xmrig::IWorker *xmrig::Workers<CpuLaunchData>::create(Thread<CpuLaunchData> *han
|
|||
}
|
||||
|
||||
return nullptr;
|
||||
# else
|
||||
assert(handle->config().intensity == 1);
|
||||
|
||||
return new CpuWorker<1>(handle->id(), handle->config());
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue