Add the get_key() guard from the other branch
This commit is contained in:
parent
2b1d841753
commit
a6e6dd2940
|
@ -142,6 +142,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)
|
||||
{
|
||||
|
@ -161,6 +164,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;
|
||||
|
|
Loading…
Reference in New Issue