Sleep.hpp
Go to the documentation of this file.
1 // @formatter:off
2 //
3 // Balau core C++ library
4 //
5 // Copyright (C) 2008 Bora Software (contact@borasoftware.com)
6 //
7 // Licensed under the Boost Software License - Version 1.0 - August 17th, 2003.
8 // See the LICENSE file for the full license text.
9 //
10 
16 
17 #ifndef COM_BORA_SOFTWARE__BALAU_SYSTEM__SLEEP
18 #define COM_BORA_SOFTWARE__BALAU_SYSTEM__SLEEP
19 
20 #include <chrono>
21 #include <thread>
22 
23 namespace Balau::System {
24 
28 class Sleep final {
32  public: static void sleep(size_t s) {
33  std::this_thread::sleep_for(std::chrono::seconds(s));
34  }
35 
39  public: static void milliSleep(size_t ms) {
40  std::this_thread::sleep_for(std::chrono::milliseconds(ms));
41  }
42 
46  public: static void microSleep(size_t us) {
47  std::this_thread::sleep_for(std::chrono::microseconds(us));
48  }
49 
53  public: static void nanoSleep(size_t ns) {
54  std::this_thread::sleep_for(std::chrono::nanoseconds(ns));
55  }
56 
58 
59  Sleep() = delete;
60  Sleep(const Sleep &) = delete;
61  Sleep & operator = (const Sleep &) = delete;
62 };
63 
64 } // namespace Balau::System
65 
66 #endif // COM_BORA_SOFTWARE__BALAU_SYSTEM__SLEEP
static void sleep(size_t s)
Sleep for the indicated number of seconds.
Definition: Sleep.hpp:32
static void milliSleep(size_t ms)
Sleep for the indicated number of milli-seconds.
Definition: Sleep.hpp:39
static void nanoSleep(size_t ns)
Sleep for the indicated number of nano-seconds.
Definition: Sleep.hpp:53
static void microSleep(size_t us)
Sleep for the indicated number of micro-seconds.
Definition: Sleep.hpp:46
Sleep utilities.
Definition: Sleep.hpp:28
System utilities and wrappers.
Definition: HttpServerConfiguration.hpp:30