ADTF  3.18.2
wait_until.h
Go to the documentation of this file.
1 
7 #pragma once
8 #include <chrono>
9 #include <thread>
10 
11 namespace adtf
12 {
13 
14 namespace testing
15 {
16 
17 namespace mega
18 {
19 
27 template <typename Callable>
28 bool wait_until(Callable&& oCallable,
29  std::chrono::milliseconds tmTimeOut,
31 {
32  auto tmStart = std::chrono::high_resolution_clock::now();
33  for (;;)
34  {
35  if (oCallable())
36  {
37  return true;
38  }
39 
40  if (std::chrono::high_resolution_clock::now() - tmStart > tmTimeOut)
41  {
42  return false;
43  }
44 
45  std::this_thread::sleep_for(tmInterval);
46  }
47 }
48 
49 }
50 
51 using mega::wait_until;
52 
53 }
54 }
bool wait_until(Callable &&oCallable, std::chrono::milliseconds tmTimeOut, std::chrono::milliseconds tmInterval=std::chrono::milliseconds{100})
Repeateatly calls oCallable until either it returns true or the timeout expires.
Definition: wait_until.h:28
Namespace for entire ADTF SDK.