Skip to content

Commit

Permalink
optimize on timedsched
Browse files Browse the repository at this point in the history
  • Loading branch information
xtaci committed Mar 22, 2020
1 parent bb1f2af commit 6f9c25a
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions timedsched.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,8 @@ func (ts *TimedSched) sched() {
// reset timer to trigger based on the top element
timer.Reset(tasks[0].ts.Sub(now))
}
case <-timer.C:
case now := <-timer.C:
for tasks.Len() > 0 {
now := time.Now()
if now.After(tasks[0].ts) {
heap.Pop(&tasks).(timedFunc).execute()
} else {
Expand Down

0 comments on commit 6f9c25a

Please sign in to comment.