summaryrefslogtreecommitdiffstats
path: root/cli-miner.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cli-miner.cpp')
-rw-r--r--cli-miner.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/cli-miner.cpp b/cli-miner.cpp
index 2cbe6d9..2f9a635 100644
--- a/cli-miner.cpp
+++ b/cli-miner.cpp
@@ -155,6 +155,9 @@ int main(int argc, char *argv[])
executor::inst()->ex_start();
+ using namespace std::chrono;
+ uint64_t lastTime = time_point_cast<milliseconds>(high_resolution_clock::now()).time_since_epoch().count();
+
int key;
while(true)
{
@@ -174,6 +177,13 @@ int main(int argc, char *argv[])
default:
break;
}
+
+ uint64_t currentTime = time_point_cast<milliseconds>(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;
OpenPOWER on IntegriCloud