Avoid deleting hashrate object
This commit is contained in:
parent
c9907eb617
commit
e4cbd36d22
3 changed files with 25 additions and 29 deletions
|
@ -48,18 +48,10 @@ inline static const char *format(double h, char *buf, size_t size)
|
|||
|
||||
Hashrate::Hashrate(size_t threads, xmrig::Controller *controller) :
|
||||
m_highest(0.0),
|
||||
m_threads(threads),
|
||||
m_threads(0),
|
||||
m_controller(controller)
|
||||
{
|
||||
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;
|
||||
}
|
||||
set_threads(threads);
|
||||
|
||||
const int printTime = controller->config()->printTime();
|
||||
|
||||
|
@ -71,8 +63,9 @@ Hashrate::Hashrate(size_t threads, xmrig::Controller *controller) :
|
|||
}
|
||||
}
|
||||
|
||||
Hashrate::~Hashrate()
|
||||
void Hashrate::set_threads(const size_t threads)
|
||||
{
|
||||
if (m_threads) {
|
||||
for (size_t i = 0; i < m_threads; i++) {
|
||||
delete [] m_counts[i];
|
||||
delete [] m_timestamps[i];
|
||||
|
@ -80,6 +73,19 @@ Hashrate::~Hashrate()
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ public:
|
|||
};
|
||||
|
||||
Hashrate(size_t threads, xmrig::Controller *controller);
|
||||
~Hashrate();
|
||||
void set_threads(size_t threads);
|
||||
double calc(size_t ms) const;
|
||||
double calc(size_t threadId, size_t ms) const;
|
||||
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)
|
||||
{
|
||||
uv_timer_stop(&m_timer);
|
||||
|
||||
if (m_hashrate) {
|
||||
m_hashrate->stop();
|
||||
delete m_hashrate;
|
||||
m_hashrate = nullptr;
|
||||
}
|
||||
|
||||
m_sequence = 0;
|
||||
m_paused = 0;
|
||||
|
||||
|
@ -262,7 +254,7 @@ void Workers::switch_algo(const xmrig::Algorithm& algorithm)
|
|||
m_status.ways += thread->multiway();
|
||||
}
|
||||
|
||||
m_hashrate = new Hashrate(threads.size(), m_controller);
|
||||
m_hashrate.set_threads(threads.size());
|
||||
|
||||
uint32_t offset = 0;
|
||||
|
||||
|
@ -273,8 +265,6 @@ void Workers::switch_algo(const xmrig::Algorithm& algorithm)
|
|||
m_workers.push_back(handle);
|
||||
handle->start(Workers::onReady);
|
||||
}
|
||||
|
||||
uv_timer_start(&m_timer, Workers::onTick, 500, 500);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue