bugfix in timer

This commit is contained in:
xtaci
2020-03-09 21:24:19 +08:00
parent 2ea2218ef0
commit dae4131c3f
+2 -4
View File
@@ -71,10 +71,8 @@ func (ts *TimedSched) sched() {
task.execute()
} else {
heap.Push(&tasks, task)
// activate timer if timer has hibernated due to 0 tasks.
if tasks.Len() == 1 {
timer.Reset(task.ts.Sub(now))
}
// reset timer to trigger based on the top element
timer.Reset(tasks[0].ts.Sub(now))
}
case <-timer.C:
for tasks.Len() > 0 {