mirror of
https://github.com/xmrig/xmrig.git
synced 2026-02-01 17:53:03 -05:00
Avoid deleting hashrate object
This commit is contained in:
@@ -48,18 +48,10 @@ inline static const char *format(double h, char *buf, size_t size)
|
|||||||
|
|
||||||
Hashrate::Hashrate(size_t threads, xmrig::Controller *controller) :
|
Hashrate::Hashrate(size_t threads, xmrig::Controller *controller) :
|
||||||
m_highest(0.0),
|
m_highest(0.0),
|
||||||
m_threads(threads),
|
m_threads(0),
|
||||||
m_controller(controller)
|
m_controller(controller)
|
||||||
{
|
{
|
||||||
m_counts = new uint64_t*[threads];
|
set_threads(threads);
|
||||||
m_timestamps = new uint64_t*[threads];
|
|
||||||
m_top = new uint32_t[threads];
|
|
||||||
|
|
||||||
for (size_t i = 0; i < threads; i++) {
|
|
||||||
m_counts[i] = new uint64_t[kBucketSize]();
|
|
||||||
m_timestamps[i] = new uint64_t[kBucketSize]();
|
|
||||||
m_top[i] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
const int printTime = controller->config()->printTime();
|
const int printTime = controller->config()->printTime();
|
||||||
|
|
||||||
@@ -71,15 +63,29 @@ Hashrate::Hashrate(size_t threads, xmrig::Controller *controller) :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Hashrate::~Hashrate()
|
void Hashrate::set_threads(const size_t threads)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < m_threads; i++) {
|
if (m_threads) {
|
||||||
delete [] m_counts[i];
|
for (size_t i = 0; i < m_threads; i++) {
|
||||||
delete [] m_timestamps[i];
|
delete [] m_counts[i];
|
||||||
|
delete [] m_timestamps[i];
|
||||||
|
}
|
||||||
|
delete [] m_counts;
|
||||||
|
delete [] m_timestamps;
|
||||||
|
delete [] m_top;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_threads = threads;
|
||||||
|
|
||||||
|
m_counts = new uint64_t*[threads];
|
||||||
|
m_timestamps = new uint64_t*[threads];
|
||||||
|
m_top = new uint32_t[threads];
|
||||||
|
|
||||||
|
for (size_t i = 0; i < threads; i++) {
|
||||||
|
m_counts[i] = new uint64_t[kBucketSize]();
|
||||||
|
m_timestamps[i] = new uint64_t[kBucketSize]();
|
||||||
|
m_top[i] = 0;
|
||||||
}
|
}
|
||||||
delete [] m_counts;
|
|
||||||
delete [] m_timestamps;
|
|
||||||
delete [] m_top;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
Hashrate(size_t threads, xmrig::Controller *controller);
|
Hashrate(size_t threads, xmrig::Controller *controller);
|
||||||
~Hashrate();
|
void set_threads(size_t threads);
|
||||||
double calc(size_t ms) const;
|
double calc(size_t ms) const;
|
||||||
double calc(size_t threadId, size_t ms) const;
|
double calc(size_t threadId, size_t ms) const;
|
||||||
void add(size_t threadId, uint64_t count, uint64_t timestamp);
|
void add(size_t threadId, uint64_t count, uint64_t timestamp);
|
||||||
|
|||||||
@@ -210,14 +210,6 @@ void Workers::start(xmrig::Controller *controller)
|
|||||||
|
|
||||||
void Workers::soft_stop() // stop current workers leaving uv stuff intact (used in switch_algo)
|
void Workers::soft_stop() // stop current workers leaving uv stuff intact (used in switch_algo)
|
||||||
{
|
{
|
||||||
uv_timer_stop(&m_timer);
|
|
||||||
|
|
||||||
if (m_hashrate) {
|
|
||||||
m_hashrate->stop();
|
|
||||||
delete m_hashrate;
|
|
||||||
m_hashrate = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_sequence = 0;
|
m_sequence = 0;
|
||||||
m_paused = 0;
|
m_paused = 0;
|
||||||
|
|
||||||
@@ -262,7 +254,7 @@ void Workers::switch_algo(const xmrig::Algorithm& algorithm)
|
|||||||
m_status.ways += thread->multiway();
|
m_status.ways += thread->multiway();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_hashrate = new Hashrate(threads.size(), m_controller);
|
m_hashrate.set_threads(threads.size());
|
||||||
|
|
||||||
uint32_t offset = 0;
|
uint32_t offset = 0;
|
||||||
|
|
||||||
@@ -273,8 +265,6 @@ void Workers::switch_algo(const xmrig::Algorithm& algorithm)
|
|||||||
m_workers.push_back(handle);
|
m_workers.push_back(handle);
|
||||||
handle->start(Workers::onReady);
|
handle->start(Workers::onReady);
|
||||||
}
|
}
|
||||||
|
|
||||||
uv_timer_start(&m_timer, Workers::onTick, 500, 500);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user