Go to the documentation of this file.00001
00008
00009
00010
00011
00012 #include <ecl/config.hpp>
00013 #if defined(ECL_IS_POSIX)
00014
00015
00016
00017
00018
00019 #include <iostream>
00020 #include "../../include/ecl/time/sleep.hpp"
00021
00022 int main() {
00023
00024 std::cout << std::endl;
00025 std::cout << "***********************************************************" << std::endl;
00026 std::cout << " Sleep" << std::endl;
00027 std::cout << "***********************************************************" << std::endl;
00028 std::cout << std::endl;
00029
00030 ecl::Duration duration(1,300000000);
00031 ecl::Sleep sleep;
00032 ecl::MilliSleep sleep_ms;
00033 ecl::MicroSleep sleep_us;
00034 ecl::NanoSleep sleep_ns;
00035
00036 std::cout << "Sleep: Duration 1s 300000000ns" << std::endl;
00037 sleep(duration);
00038 std::cout << "Sleep: 1s" << std::endl;
00039 sleep(1);
00040 std::cout << "MilliSleep: 500 x 2 = 1s" << std::endl;
00041 for ( int i = 0; i < 2; ++i ) { sleep_ms(500); }
00042 std::cout << "MicroSleep: 500,000 x 2 = 1s" << std::endl;
00043 for ( int i = 0; i < 2; ++i ) { sleep_us(500000); }
00044 std::cout << "NanoSleep: 500,000,000 x 2 = 1s" << std::endl;
00045 for ( int i = 0; i < 2; ++i ) { sleep_ns(500000000); }
00046
00047
00048 std::cout << std::endl;
00049 std::cout << "***********************************************************" << std::endl;
00050 std::cout << " Pre Configured Sleep" << std::endl;
00051 std::cout << "***********************************************************" << std::endl;
00052 std::cout << std::endl;
00053
00054 ecl::Sleep sleep_1_3s(duration);
00055 std::cout << "Sleep" << std::endl;
00056 sleep_1_3s();
00057 ecl::MilliSleep sleep_1400ms(1400);
00058 std::cout << "MilliSleep" << std::endl;
00059 sleep_1400ms();
00060 ecl::MicroSleep sleep_1400us(1400);
00061 std::cout << "MicroSleep" << std::endl;
00062 sleep_1400us();
00063 ecl::NanoSleep sleep_1400ns(1400);
00064 std::cout << "NanoSleep" << std::endl;
00065 sleep_1400ns();
00066
00067 std::cout << std::endl;
00068 std::cout << "***********************************************************" << std::endl;
00069 std::cout << " Passed" << std::endl;
00070 std::cout << "***********************************************************" << std::endl;
00071 std::cout << std::endl;
00072
00073 return 0;
00074 }
00075
00076 #else
00077
00078 #include <iostream>
00079
00080
00081
00082
00083
00084 int main(int argc, char **argv) {
00085
00086 std::cout << "This platform is not yet supported." << std::endl;
00087
00088 return 0;
00089 }
00090
00091 #endif