Created
May 11, 2020 20:56
-
-
Save r2p2/7e3960a435f226f39cc2d9100b2b1bf6 to your computer and use it in GitHub Desktop.
sleep_until 100 % cpu usage on wsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// g++ example.cc | |
#include <chrono> | |
#include <iostream> | |
#include <string> | |
#include <thread> | |
int main() | |
{ | |
std::chrono::milliseconds delay(1000); | |
while (true) | |
{ | |
std::chrono::high_resolution_clock::time_point end = std::chrono::high_resolution_clock::now() + delay; | |
std::this_thread::sleep_until(end); | |
std::cout << "a" << std::endl; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment