examples/sleep.cpp
Go to the documentation of this file.
1 
8 /*****************************************************************************
9 ** Platform Check
10 *****************************************************************************/
11 
12 #include <ecl/config.hpp>
13 
14 /*****************************************************************************
15 ** Includes
16 *****************************************************************************/
17 
18 #include <iostream>
19 #include "../../include/ecl/time/sleep.hpp"
20 
21 int main() {
22 
23  std::cout << std::endl;
24  std::cout << "***********************************************************" << std::endl;
25  std::cout << " Sleep" << std::endl;
26  std::cout << "***********************************************************" << std::endl;
27  std::cout << std::endl;
28 
29  ecl::Duration duration(1,300000000);
30  ecl::MilliSleep sleep;
31  ecl::MilliSleep sleep_ms;
32  ecl::MicroSleep sleep_us;
33  ecl::NanoSleep sleep_ns;
34 
35  std::cout << "Sleep: Duration 1s 300000000ns" << std::endl;
36  sleep(duration);
37  std::cout << "Sleep: 1s" << std::endl;
38  sleep(1);
39  std::cout << "MilliSleep: 500 x 2 = 1s" << std::endl;
40  for ( int i = 0; i < 2; ++i ) { sleep_ms(500); }
41  std::cout << "MicroSleep: 500,000 x 2 = 1s" << std::endl;
42  for ( int i = 0; i < 2; ++i ) { sleep_us(500000); }
43  std::cout << "NanoSleep: 500,000,000 x 2 = 1s" << std::endl;
44  for ( int i = 0; i < 2; ++i ) { sleep_ns(500000000); }
45 
46  std::cout << std::endl;
47  std::cout << "***********************************************************" << std::endl;
48  std::cout << " Pre Configured Sleep" << std::endl;
49  std::cout << "***********************************************************" << std::endl;
50  std::cout << std::endl;
51 
52  ecl::Sleep sleep_1_3s(duration);
53  std::cout << "Sleep" << std::endl;
54  sleep_1_3s();
55  ecl::MilliSleep sleep_1400ms(1400);
56  std::cout << "MilliSleep" << std::endl;
57  sleep_1400ms();
58  ecl::MicroSleep sleep_1400us(1400);
59  std::cout << "MicroSleep" << std::endl;
60  sleep_1400us();
61  ecl::NanoSleep sleep_1400ns(1400);
62  std::cout << "NanoSleep" << std::endl;
63  sleep_1400ns();
64 
65  std::cout << std::endl;
66  std::cout << "***********************************************************" << std::endl;
67  std::cout << " Passed" << std::endl;
68  std::cout << "***********************************************************" << std::endl;
69  std::cout << std::endl;
70 
71  return 0;
72 }
main
int main()
Definition: examples/sleep.cpp:21
ecl::Duration
TimeStamp Duration
Convenience typedef to associate timestamps with the concept of durations.
Definition: duration.hpp:47
config.hpp


ecl_time
Author(s): Daniel Stonier
autogenerated on Wed Mar 2 2022 00:16:19