Skip to content

Instantly share code, notes, and snippets.

@the-nose-knows
Created June 20, 2018 03:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save the-nose-knows/760f99aed46b43ca3b6b3f3a2ecc6bb1 to your computer and use it in GitHub Desktop.
Save the-nose-knows/760f99aed46b43ca3b6b3f3a2ecc6bb1 to your computer and use it in GitHub Desktop.
A non-busy C++ thread sleeper, static class meant to be included as-needed; sleeps whatever thread it's used on.
#ifndef DELAY_H
#define DELAY_H
#include <chrono>
#include <thread>
class Delay
{
private:
Delay(){};
~Delay(){};
public:
static void hour_delay( __int64 hours) { std::this_thread::sleep_for(std::chrono::hours(hours)); };
static void minute_delay( __int64 minutes) { std::this_thread::sleep_for(std::chrono::minutes(minutes)); };
static void second_delay( __int64 seconds) { std::this_thread::sleep_for(std::chrono::seconds(seconds)); };
static void millisecond_delay( __int64 milliseconds) { std::this_thread::sleep_for(std::chrono::milliseconds(milliseconds)); };
static void microsecond_delay( __int64 microseconds) { std::this_thread::sleep_for(std::chrono::microseconds(microseconds)); };
static void nanosecond_delay( __int64 nanoseconds) { std::this_thread::sleep_for(std::chrono::nanoseconds(nanoseconds)); };
};
#endif // DELAY_H
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment