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 ()() {
43 int result = nanosleep(&required, &remaining);
47 void Sleep::operator ()(
const Duration &duration) {
48 required.tv_sec = duration.sec();
49 required.tv_nsec = duration.nsec();
50 int result = nanosleep(&required, &remaining);
54 void Sleep::operator ()(
const unsigned long &seconds) {
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 ()() {
71 int result = nanosleep(&required, &remaining);
75 void MilliSleep::operator ()(
const unsigned long &milliseconds) {
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 ()() {
93 int result = nanosleep(&required, &remaining);
97 void MicroSleep::operator ()(
const unsigned long µ_seconds) {
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 ()() {
113 int result = nanosleep(&required, &remaining);
117 void NanoSleep::operator ()(
const unsigned long &nanoseconds) {
118 required.tv_nsec = nanoseconds;
119 int result = nanosleep(&required, &remaining);
Embedded control libraries.
#define ecl_assert_throw(expression, exception)
TimeStamp Duration
Convenience typedef to associate timestamps with the concept of durations.