diff --git a/cli-miner.cpp b/cli-miner.cpp index a4c509b..051a00f 100644 --- a/cli-miner.cpp +++ b/cli-miner.cpp @@ -142,6 +142,9 @@ int main(int argc, char *argv[]) executor::inst()->ex_start(); + using namespace std::chrono; + uint64_t lastTime = time_point_cast(high_resolution_clock::now()).time_since_epoch().count(); + int key; while(true) { @@ -161,6 +164,13 @@ int main(int argc, char *argv[]) default: break; } + + uint64_t currentTime = time_point_cast(high_resolution_clock::now()).time_since_epoch().count(); + + /* Hard guard to make sure we never get called more than twice per second */ + if( currentTime - lastTime < 500) + std::this_thread::sleep_for(std::chrono::milliseconds(500 - (currentTime - lastTime))); + lastTime = currentTime; } return 0;