Add the get_key() guard from the other branch

This commit is contained in:
fireice-uk 2017-05-26 18:59:49 +01:00
parent 2b1d841753
commit a6e6dd2940
1 changed files with 10 additions and 0 deletions

View File

@ -142,6 +142,9 @@ int main(int argc, char *argv[])
executor::inst()->ex_start(); 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; int key;
while(true) while(true)
{ {
@ -161,6 +164,13 @@ int main(int argc, char *argv[])
default: default:
break; 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; return 0;