Skip to content

Instantly share code, notes, and snippets.

@tzuhsun
Last active January 4, 2018 09:07
Show Gist options
  • Save tzuhsun/a30b9da494d339f16e29a1f8ea537c1b to your computer and use it in GitHub Desktop.
Save tzuhsun/a30b9da494d339f16e29a1f8ea537c1b to your computer and use it in GitHub Desktop.
C++ 11 sleep function
// Reference
// https://github.com/ErikDubbelboer/node-sleep/issues/24
#include <chrono>
#include <thread>
std::this_thread::sleep_for(std::chrono::nanoseconds(ssec)); /* signed integer of 64+ bits */
std::this_thread::sleep_for(std::chrono::microseconds(usec)); /* signed integer of 55+ bits */
std::this_thread::sleep_for(std::chrono::milliseconds(ms)); /* signed integer of 45+ bits */
std::this_thread::sleep_for(std::chrono::seconds(sec)); /* signed integer of 35+ bits */
std::this_thread::sleep_for(std::chrono::minutes(min)); /* signed integer of 29+ bits */
std::this_thread::sleep_for(std::chrono::hours(hrs)); /* signed integer of 23+ bits */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment