sleep.cpp
Go to the documentation of this file.
00001 
00008 /*****************************************************************************
00009 ** Platform Check
00010 *****************************************************************************/
00011 
00012 #include <ecl/config.hpp>
00013 
00014 /*****************************************************************************
00015 ** Includes
00016 *****************************************************************************/
00017 
00018 #include <iostream>
00019 #include "../../include/ecl/time/sleep.hpp"
00020 
00021 int main() {
00022 
00023     std::cout << std::endl;
00024     std::cout << "***********************************************************" << std::endl;
00025     std::cout << "                   Sleep" << std::endl;
00026     std::cout << "***********************************************************" << std::endl;
00027     std::cout << std::endl;
00028 
00029     ecl::Duration duration(1,300000000);
00030     ecl::MilliSleep sleep;
00031     ecl::MilliSleep sleep_ms;
00032     ecl::MicroSleep sleep_us;
00033     ecl::NanoSleep sleep_ns;
00034 
00035     std::cout << "Sleep: Duration 1s 300000000ns" << std::endl;
00036     sleep(duration);
00037     std::cout << "Sleep: 1s" << std::endl;
00038     sleep(1);
00039     std::cout << "MilliSleep: 500 x 2 = 1s" << std::endl;
00040     for ( int i = 0; i < 2; ++i ) { sleep_ms(500); }
00041     std::cout << "MicroSleep: 500,000 x 2 = 1s" << std::endl;
00042     for ( int i = 0; i < 2; ++i ) { sleep_us(500000); }
00043     std::cout << "NanoSleep:  500,000,000 x 2 = 1s" << std::endl;
00044     for ( int i = 0; i < 2; ++i ) { sleep_ns(500000000); }
00045 
00046     std::cout << std::endl;
00047     std::cout << "***********************************************************" << std::endl;
00048     std::cout << "               Pre Configured Sleep" << std::endl;
00049     std::cout << "***********************************************************" << std::endl;
00050     std::cout << std::endl;
00051 
00052     ecl::Sleep sleep_1_3s(duration);
00053     std::cout << "Sleep" << std::endl;
00054     sleep_1_3s();
00055     ecl::MilliSleep sleep_1400ms(1400);
00056     std::cout << "MilliSleep" << std::endl;
00057     sleep_1400ms();
00058     ecl::MicroSleep sleep_1400us(1400);
00059     std::cout << "MicroSleep" << std::endl;
00060     sleep_1400us();
00061     ecl::NanoSleep sleep_1400ns(1400);
00062     std::cout << "NanoSleep" << std::endl;
00063     sleep_1400ns();
00064 
00065     std::cout << std::endl;
00066     std::cout << "***********************************************************" << std::endl;
00067     std::cout << "                      Passed" << std::endl;
00068     std::cout << "***********************************************************" << std::endl;
00069     std::cout << std::endl;
00070 
00071     return 0;
00072 }


ecl_time
Author(s): Daniel Stonier
autogenerated on Wed Aug 26 2015 11:27:17