From d882773789ea3894de7163f7bb880c5b23072882 Mon Sep 17 00:00:00 2001 From: s_nakamoto Date: Thu, 8 Jul 2010 16:14:56 +0000 Subject: Laszlo's fix to make generate threads idle priority on Linux, replaced some wxBase dependencies: wxMutex, wxFileExists, wxStandardPaths, wxGetLocalTimeMillis git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@99 1a98c847-1fd6-4fd8-948a-caf3550aa51b --- main.cpp | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) (limited to 'main.cpp') diff --git a/main.cpp b/main.cpp index 2b08744d4e..803548e61e 100644 --- a/main.cpp +++ b/main.cpp @@ -1477,7 +1477,10 @@ bool CheckDiskSpace(int64 nAdditionalBytes) if (nFreeBytesAvailable < (int64)15000000 + nAdditionalBytes) { fShutdown = true; + printf("*** %s***\n", _("Warning: Disk space is low ")); +#if wxUSE_GUI ThreadSafeMessageBox(_("Warning: Disk space is low "), "Bitcoin", wxOK | wxICON_EXCLAMATION); +#endif CreateThread(Shutdown, NULL); return false; } @@ -2713,25 +2716,32 @@ void BitcoinMiner() if ((++tmp.block.nNonce & nMask) == 0) { // Meter hashes/sec - static int64 nHashCounter; - static int64 nLastTick; - if (nLastTick == 0) - nLastTick = GetTimeMillis(); + static int64 nTimerStart; + static int nHashCounter; + if (nTimerStart == 0) + nTimerStart = GetTimeMillis(); else - nHashCounter += nMask + 1; - if (GetTimeMillis() - nLastTick > 4000) + nHashCounter++; + if (GetTimeMillis() - nTimerStart > 4000) { - double dHashesPerSec = 1000.0 * nHashCounter / (GetTimeMillis() - nLastTick); - nLastTick = GetTimeMillis(); - nHashCounter = 0; - string strStatus = strprintf(" %.0f khash/s", dHashesPerSec/1000.0); - UIThreadCall(bind(CalledSetStatusBar, strStatus, 0)); - static int64 nLogTime; - if (GetTime() - nLogTime > 30 * 60) + static CCriticalSection cs; + CRITICAL_BLOCK(cs) { - nLogTime = GetTime(); - printf("%s ", DateTimeStrFormat("%x %H:%M", GetTime()).c_str()); - printf("hashmeter %3d CPUs %6.0f khash/s\n", vnThreadsRunning[3], dHashesPerSec/1000.0); + if (GetTimeMillis() - nTimerStart > 4000) + { + double dHashesPerSec = 1000.0 * (nMask+1) * nHashCounter / (GetTimeMillis() - nTimerStart); + nTimerStart = GetTimeMillis(); + nHashCounter = 0; + string strStatus = strprintf(" %.0f khash/s", dHashesPerSec/1000.0); + UIThreadCall(bind(CalledSetStatusBar, strStatus, 0)); + static int64 nLogTime; + if (GetTime() - nLogTime > 30 * 60) + { + nLogTime = GetTime(); + printf("%s ", DateTimeStrFormat("%x %H:%M", GetTime()).c_str()); + printf("hashmeter %3d CPUs %6.0f khash/s\n", vnThreadsRunning[3], dHashesPerSec/1000.0); + } + } } } -- cgit v1.2.3