2
0
mirror of https://github.com/hibiken/asynq.git synced 2024-11-10 03:21:55 +08:00

Update forwarder to use time.Timer

This commit is contained in:
Ken Hibino 2022-03-06 07:46:34 -08:00
parent ed69667e86
commit 088be63ee4

View File

@ -56,13 +56,15 @@ func (f *forwarder) start(wg *sync.WaitGroup) {
wg.Add(1)
go func() {
defer wg.Done()
timer := time.NewTimer(f.avgInterval)
for {
select {
case <-f.done:
f.logger.Debug("Forwarder done")
return
case <-time.After(f.avgInterval):
case <-timer.C:
f.exec()
timer.Reset(f.avgInterval)
}
}
}()