Handle offset change in PhasedLoop and PhasedLoopHandler
When the PhasedLoop offset_ is changed, the last_time_ must be adjusted
to have an even interval. Additionally, in the PhaseLoopHandler Call
method, schedule has to be called after fn_ because if fn_ changes
the offset then it will not be updated on the next callback since
schedule has already scheduled the next time.
Change-Id: I12110134f00ee948f986e0df9f8304fbc2b08c31
Signed-off-by: milind <milind.upadhyay@gmail.com>
diff --git a/aos/events/event_loop.cc b/aos/events/event_loop.cc
index 08fa7fd..29e4c22 100644
--- a/aos/events/event_loop.cc
+++ b/aos/events/event_loop.cc
@@ -70,9 +70,9 @@
Schedule(sleep_time);
},
monotonic_now);
- // The first time, we'll double count. Reschedule here will count cycles
- // elapsed before now, and then the reschedule before runing the handler
- // will count the time that elapsed then. So clear the count here.
+ // Reschedule here will count cycles elapsed before now, and then the
+ // reschedule before running the handler will count the time that elapsed
+ // then. So clear the count here.
cycles_elapsed_ = 0;
});
}