OpenDaVINCI  4.15.3
WIN32ConcurrencyFactoryWorker.h
Go to the documentation of this file.
1 
20 #ifndef OPENDAVINCI_CORE_WRAPPER_WIN32_WIN32CONCURRENCYFACTORYWORKER_H_
21 #define OPENDAVINCI_CORE_WRAPPER_WIN32_WIN32CONCURRENCYFACTORYWORKER_H_
22 
23 // Using c++11 standard.
24 #include <chrono>
25 #include <thread>
26 
28 
31 
33 
34 namespace odcore {
35  namespace wrapper {
36 
37  using namespace std;
38 
40  public:
41  static Thread* createThread(Runnable &runnable) {
42  return new odcore::wrapper::WIN32Impl::WIN32Thread(runnable);
43  };
44 
45  static void usleepFor(const long &microseconds) {
46  std::this_thread::sleep_until(std::chrono::steady_clock::now() + std::chrono::microseconds(microseconds));
47  };
48 
49  static void usleepUntil(const long &seconds, const long &partialMicroseconds) {
50  using Clock = std::chrono::high_resolution_clock;
51  using TimePoint = std::chrono::time_point<Clock>;
52 
53  const Clock::duration sleepUntilDuration = std::chrono::seconds(seconds) + std::chrono::microseconds(partialMicroseconds);
54  const TimePoint timePoint(sleepUntilDuration);
55 
56  std::this_thread::sleep_until(timePoint);
57  };
58  };
59  }
60 } // odcore::wrapper
61 
62 #endif /*OPENDAVINCI_CORE_WRAPPER_WIN32_WIN32CONCURRENCYFACTORY_H_*/
static void usleepFor(const long &microseconds)
Definition: WIN32ConcurrencyFactoryWorker.h:45
static void usleepUntil(const long &seconds, const long &partialMicroseconds)
Definition: WIN32ConcurrencyFactoryWorker.h:49
Definition: ConcurrencyFactoryWorker.h:42
Definition: WIN32Thread.h:48
#define OPENDAVINCI_API
Definition: opendavinci.h:67
Definition: Runnable.h:35
static Thread * createThread(Runnable &runnable)
Definition: WIN32ConcurrencyFactoryWorker.h:41
Definition: base/Thread.h:34
Definition: SystemLibraryProducts.h:29