12 #ifndef ECL_TIME_SLEEP_POS_HPP_
13 #define ECL_TIME_SLEEP_POS_HPP_
20 #if defined(ECL_IS_POSIX)
82 Sleep(
const unsigned long &seconds = 0);
111 void operator()(
const unsigned long &seconds);
121 void operator()(
const Duration &duration);
124 timespec required, remaining;
153 MilliSleep(
const unsigned long &milliseconds = 0);
155 virtual ~MilliSleep() {}
183 void operator()(
const unsigned long &milliseconds);
185 timespec required, remaining;
214 MicroSleep(
const unsigned long µseconds = 0);
216 virtual ~MicroSleep() {}
244 void operator()(
const unsigned long µ_seconds);
246 timespec required, remaining;
275 NanoSleep(
const unsigned long &nanoseconds = 0);
277 virtual ~NanoSleep() {}
305 void operator()(
const unsigned long &nanoseconds);
307 timespec required, remaining;
317 #if defined(ECL_HAS_EXCEPTIONS)
332 int error_result = errno;
333 switch (error_result) {
334 case ( EINTR ) :
return StandardException(loc,
ecl::InterruptedError,
"A posix signal interrupted the sleep.");
335 case ( EINVAL ) :
return StandardException(loc,
ecl::InvalidInputError,
"Specified value was negative or exceeded resolution range.\n\n Sleep: [N/A]\n MilliSleep: [0-1000]\n MicroSleep: [0-1x10^6]\n NanoSleep: [0-1x10^9]\n");
336 case ( EFAULT ) :
return StandardException(loc,
ecl::MemoryError,
"Internal posix issue copying information from user space.");
339 std::ostringstream ostream;
340 ostream <<
"Unknown posix error " << error_result <<
": " << strerror(error_result) <<
".";
341 return StandardException(loc,
UnknownError, ostream.str());