13 #if defined(ECL_IS_POSIX) 20 #include "../../include/ecl/time/duration.hpp" 21 #include "../../include/ecl/time/sleep_pos.hpp" 32 Sleep::Sleep(
const Duration &duration) {
33 required.tv_sec = duration.sec();
34 required.tv_nsec = duration.nsec();
37 Sleep::Sleep(
const unsigned long &seconds) {
38 required.tv_sec = seconds;
42 void Sleep::operator ()() ecl_assert_throw_decl(StandardException) {
43 int result = nanosleep(&required, &remaining);
48 required.tv_sec = duration.sec();
49 required.tv_nsec = duration.nsec();
50 int result = nanosleep(&required, &remaining);
55 required.tv_sec = seconds;
57 int result = nanosleep(&required, &remaining);
65 MilliSleep::MilliSleep(
const unsigned long &milliseconds) {
66 required.tv_sec = milliseconds/1000;
67 required.tv_nsec = (milliseconds%1000)*1000000;
70 void MilliSleep::operator ()() ecl_assert_throw_decl(StandardException) {
71 int result = nanosleep(&required, &remaining);
75 void MilliSleep::operator ()(
const unsigned long &milliseconds)
ecl_assert_throw_decl(StandardException) {
76 required.tv_sec = milliseconds/1000;
77 required.tv_nsec = (milliseconds%1000)*1000000;
79 int result = nanosleep(&required, &remaining);
87 MicroSleep::MicroSleep(
const unsigned long µseconds) {
88 required.tv_sec = microseconds/1000000;
89 required.tv_nsec = (microseconds%1000000)*1000;
92 void MicroSleep::operator ()() ecl_assert_throw_decl(StandardException) {
93 int result = nanosleep(&required, &remaining);
97 void MicroSleep::operator ()(
const unsigned long µ_seconds)
ecl_assert_throw_decl(StandardException) {
98 required.tv_nsec = 1000*micro_seconds;
99 int result = nanosleep(&required, &remaining);
107 NanoSleep::NanoSleep(
const unsigned long &nanoseconds) {
108 required.tv_sec = nanoseconds/1000000000;
109 required.tv_nsec = nanoseconds%1000000000;
112 void NanoSleep::operator ()() ecl_assert_throw_decl(StandardException) {
113 int result = nanosleep(&required, &remaining);
117 void NanoSleep::operator ()(
const unsigned long &nanoseconds)
ecl_assert_throw_decl(StandardException) {
118 required.tv_nsec = nanoseconds;
119 int result = nanosleep(&required, &remaining);
Embedded control libraries.
#define ecl_assert_throw(expression, exception)
#define ecl_assert_throw_decl(exception)
TimeStamp Duration
Convenience typedef to associate timestamps with the concept of durations.