brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame^] | 1 | #include "aos/common/logging/logging.h" |
| 2 | #include "aos/common/control_loop/Timing.h" |
| 3 | |
| 4 | #include "aos/common/time.h" |
| 5 | |
| 6 | namespace aos { |
| 7 | namespace time { |
| 8 | |
| 9 | void PhasedLoopXMS(int ms, int offset) { |
| 10 | // TODO(brians): Rewrite this cleaner. |
| 11 | // TODO(brians): Tests! |
| 12 | int64_t period_nsec = Time::InMS(ms).nsec(); |
| 13 | SleepUntil(Time::InNS((Time::Now().ToNSec() / period_nsec + |
| 14 | static_cast<int64_t>(1)) * period_nsec + |
| 15 | Time::InUS(offset).ToNSec())); |
| 16 | } |
| 17 | |
| 18 | } // namespace timing |
| 19 | } // namespace aos |