Created
June 20, 2018 03:38
-
-
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.
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
#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