Use AtomicTimer for metrics screen thread count

This commit is contained in:
Jack Grigg 2017-02-14 22:06:35 +00:00
parent 2854c4e366
commit 0d0265fd11
No known key found for this signature in database
GPG Key ID: 6A6914DAFBEA00DA
2 changed files with 10 additions and 9 deletions

View File

@ -45,6 +45,12 @@ bool AtomicTimer::running()
return threads > 0;
}
uint64_t AtomicTimer::threadCount()
{
std::unique_lock<std::mutex> lock(mtx);
return threads;
}
double AtomicTimer::rate(const AtomicCounter& count)
{
std::unique_lock<std::mutex> lock(mtx);
@ -191,15 +197,8 @@ int printMiningStatus(bool mining)
int lines = 1;
if (mining) {
int nThreads = GetArg("-genproclimit", 1);
if (nThreads < 0) {
// In regtest threads defaults to 1
if (Params().DefaultMinerThreads())
nThreads = Params().DefaultMinerThreads();
else
nThreads = boost::thread::hardware_concurrency();
}
if (miningTimer.running()) {
auto nThreads = miningTimer.threadCount();
if (nThreads > 0) {
std::cout << strprintf(_("You are mining with the %s solver on %d threads."),
GetArg("-equihashsolver", "default"), nThreads) << std::endl;
} else {

View File

@ -49,6 +49,8 @@ public:
bool running();
uint64_t threadCount();
double rate(const AtomicCounter& count);
};