Skip to content

Instantly share code, notes, and snippets.

@r2p2
Created May 11, 2020 20:56
Show Gist options
  • Save r2p2/7e3960a435f226f39cc2d9100b2b1bf6 to your computer and use it in GitHub Desktop.
Save r2p2/7e3960a435f226f39cc2d9100b2b1bf6 to your computer and use it in GitHub Desktop.
sleep_until 100 % cpu usage on wsl
// 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