diff options
author | fireice-uk <fireice2@o2.pl> | 2017-01-11 02:44:28 +0000 |
---|---|---|
committer | fireice-uk <fireice2@o2.pl> | 2017-01-11 02:44:28 +0000 |
commit | fb6bf3ec4bc85cbf1f703f9f6b930c865479b4e8 (patch) | |
tree | 5b2efa7f7e78ce218a4f048fa1b24bdcd5f55ed1 /executor.cpp | |
parent | 947cb8004f5857393645b37861ebfb6f8873fd41 (diff) | |
download | xmr-stak-fb6bf3ec4bc85cbf1f703f9f6b930c865479b4e8.zip xmr-stak-fb6bf3ec4bc85cbf1f703f9f6b930c865479b4e8.tar.gz |
v1.0.1 candidate - new more verbose level
Diffstat (limited to 'executor.cpp')
-rw-r--r-- | executor.cpp | 46 |
1 files changed, 30 insertions, 16 deletions
diff --git a/executor.cpp b/executor.cpp index 8da2a23..16a5a90 100644 --- a/executor.cpp +++ b/executor.cpp @@ -33,6 +33,12 @@ executor::executor() my_thd = nullptr; } +void executor::push_timed_event(ex_event&& ev, size_t sec) +{ + std::unique_lock<std::mutex> lck(timed_event_mutex); + lTimedEvents.emplace_back(std::move(ev), sec_to_ticks(sec)); +} + void executor::ex_clock_thd() { size_t iSwitchPeriod = sec_to_ticks(iDevDonatePeriod); @@ -52,19 +58,21 @@ void executor::ex_clock_thd() push_event(ex_event(EV_PERF_TICK)); - if(iReconnectCountdown != 0) + // Service timed events + std::unique_lock<std::mutex> lck(timed_event_mutex); + std::list<timed_event>::iterator ev = lTimedEvents.begin(); + while (ev != lTimedEvents.end()) { - iReconnectCountdown--; - if(iReconnectCountdown == 0) - push_event(ex_event(EV_RECONNECT, usr_pool_id)); - } - - if(iDevDisconnectCountdown != 0) - { - iDevDisconnectCountdown--; - if(iDevDisconnectCountdown == 0) - push_event(ex_event(EV_DEV_POOL_EXIT)); + ev->ticks_left--; + if(ev->ticks_left == 0) + { + push_event(std::move(ev->event)); + ev = lTimedEvents.erase(ev); + } + else + ev++; } + lck.unlock(); if(iDevPortion == 0) continue; @@ -90,7 +98,7 @@ void executor::sched_reconnect() auto work = minethd::miner_work(); minethd::switch_work(work); - iReconnectCountdown = sec_to_ticks(rt); + push_timed_event(ex_event(EV_RECONNECT, usr_pool_id), rt); } void executor::log_socket_error(std::string&& sError) @@ -312,7 +320,7 @@ void executor::on_switch_pool(size_t pool_id) minethd::switch_work(oWork); if(dev_pool->is_running()) - iDevDisconnectCountdown = sec_to_ticks(5); + push_timed_event(ex_event(EV_DEV_POOL_EXIT), 5); } } @@ -320,9 +328,6 @@ void executor::ex_main() { assert(1000 % iTickTime == 0); - iReconnectCountdown = 0; - iDevDisconnectCountdown = 0; - minethd::miner_work oWork = minethd::miner_work(); pvThreads = minethd::thread_starter(oWork); telem = new telemetry(pvThreads->size()); @@ -341,6 +346,10 @@ void executor::ex_main() // be here even if our first result is a failure vMineResults.emplace_back(); + // If the user requested it, start the autohash printer + if(jconf::inst()->GetVerboseLevel() >= 4) + push_timed_event(ex_event(EV_HASHRATE_LOOP), jconf::inst()->GetAutohashTime()); + size_t cnt = 0, i; while (true) { @@ -403,6 +412,11 @@ void executor::ex_main() connection_report(); break; + case EV_HASHRATE_LOOP: + hashrate_report(); + push_timed_event(ex_event(EV_HASHRATE_LOOP), jconf::inst()->GetAutohashTime()); + break; + case EV_INVALID_VAL: default: assert(false); |