Go to the documentation of this file.00001
00008
00009
00010
00011
00012 #include <ecl/config.hpp>
00013 #if defined(ECL_IS_WIN32)
00014
00015
00016
00017
00018
00019 #include <ecl/errors/macros.hpp>
00020 #include "../../include/ecl/time/duration.hpp"
00021 #include "../../include/ecl/time/sleep_win.hpp"
00022
00023 #include <iostream>
00024 #include <ecl/time_lite/functions.hpp>
00025
00026
00027
00028
00029
00030 namespace ecl {
00031
00032
00033
00034
00035 Sleep::Sleep(const Duration &duration) {
00036 required.tv_sec = duration.sec();
00037 required.tv_nsec = duration.nsec();
00038 }
00039
00040 Sleep::Sleep(const unsigned long &seconds) {
00041 required.tv_sec = seconds;
00042 required.tv_nsec = 0;
00043 }
00044
00045 void Sleep::operator ()() ecl_assert_throw_decl(StandardException) {
00046 TimeError result = sleep(required);
00047 ecl_assert_throw( result == TimeError(NoError), time::throwSleepException(LOC) );
00048 }
00049
00050 void Sleep::operator ()(const Duration &duration) ecl_assert_throw_decl(StandardException) {
00051 required.tv_sec = duration.sec();
00052 required.tv_nsec = duration.nsec();
00053 TimeError result = sleep(required);
00054 ecl_assert_throw( result == TimeError(NoError), time::throwSleepException(LOC) );
00055 }
00056
00057 void Sleep::operator ()(const unsigned long &seconds) ecl_assert_throw_decl(StandardException) {
00058 required.tv_sec = seconds;
00059 required.tv_nsec = 0;
00060 TimeError result = sleep(required);
00061 ecl_assert_throw( result == TimeError(NoError), time::throwSleepException(LOC) );
00062 }
00063
00064
00065
00066
00067
00068 MilliSleep::MilliSleep(const unsigned long &milliseconds) {
00069 required.tv_sec = milliseconds/1000;
00070 required.tv_nsec = (milliseconds%1000)*1000000;
00071 }
00072
00073 void MilliSleep::operator ()() ecl_assert_throw_decl(StandardException) {
00074 TimeError result = sleep(required);
00075 ecl_assert_throw( result == TimeError(NoError), time::throwSleepException(LOC) );
00076 }
00077
00078 void MilliSleep::operator ()(const unsigned long &milliseconds) ecl_assert_throw_decl(StandardException) {
00079 required.tv_sec = milliseconds/1000;
00080 required.tv_nsec = (milliseconds%1000)*1000000;
00081
00082 TimeError result = sleep(required);
00083 ecl_assert_throw( result == TimeError(NoError), time::throwSleepException(LOC) );
00084 }
00085
00086
00087
00088
00089
00090 MicroSleep::MicroSleep(const unsigned long µseconds) {
00091 required.tv_sec = microseconds/1000000;
00092 required.tv_nsec = (microseconds%1000000)*1000;
00093 }
00094
00095 void MicroSleep::operator ()() ecl_assert_throw_decl(StandardException) {
00096 TimeError result = sleep(required);
00097 ecl_assert_throw( result == TimeError(NoError), time::throwSleepException(LOC) );
00098 }
00099
00100 void MicroSleep::operator ()(const unsigned long µ_seconds) ecl_assert_throw_decl(StandardException) {
00101 required.tv_nsec = 1000*micro_seconds;
00102 TimeError result = sleep(required);
00103 ecl_assert_throw( result == TimeError(NoError), time::throwSleepException(LOC) );
00104 }
00105
00106
00107
00108
00109
00110 NanoSleep::NanoSleep(const unsigned long &nanoseconds) {
00111 required.tv_sec = nanoseconds/1000000000;
00112 required.tv_nsec = nanoseconds%1000000000;
00113 }
00114
00115 void NanoSleep::operator ()() ecl_assert_throw_decl(StandardException) {
00116 TimeError result = sleep(required);
00117 ecl_assert_throw( result == TimeError(NoError), time::throwSleepException(LOC) );
00118 }
00119
00120 void NanoSleep::operator ()(const unsigned long &nanoseconds) ecl_assert_throw_decl(StandardException) {
00121 required.tv_nsec = nanoseconds;
00122 TimeError result = sleep(required);
00123 ecl_assert_throw( result == TimeError(NoError), time::throwSleepException(LOC) );
00124 }
00125
00126 }
00127
00128 #endif
00129