MCPcopy Create free account
hub / github.com/AutonomousFieldRoboticsLab/SVIn / sleep

Method sleep

okvis_ros/okvis/okvis_time/src/Time.cpp:295–323  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

293}
294
295bool Duration::sleep() const {
296 if (Time::useSystemTime()) {
297 return okvis_wallsleep(sec, nsec);
298 } else {
299 Time start = Time::now();
300 Time end = start + *this;
301 if (start.isZero()) {
302 end = TIME_MAX;
303 }
304
305 while ((Time::now() < end)) {
306 okvis_wallsleep(0, 1000000);
307
308 // If we started at time 0 wait for the first actual time to arrive before starting the timer on
309 // our sleep
310 if (start.isZero()) {
311 start = Time::now();
312 end = start + *this;
313 }
314
315 // If time jumped backwards from when we started sleeping, return immediately
316 if (Time::now() < start) {
317 return false;
318 }
319 }
320
321 return true;
322 }
323}
324
325std::ostream& operator<<(std::ostream& os, const WallTime& rhs) {
326 os << rhs.sec << "." << std::setw(9) << std::setfill('0') << rhs.nsec;

Callers 1

sleepUntilMethod · 0.80

Calls 2

okvis_wallsleepFunction · 0.85
isZeroMethod · 0.45

Tested by

no test coverage detected