mirror of
https://github.com/hibiken/asynq.git
synced 2024-12-25 23:32:17 +08:00
Update forwarder to use time.Timer
This commit is contained in:
parent
ed69667e86
commit
088be63ee4
@ -56,13 +56,15 @@ func (f *forwarder) start(wg *sync.WaitGroup) {
|
|||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
|
timer := time.NewTimer(f.avgInterval)
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-f.done:
|
case <-f.done:
|
||||||
f.logger.Debug("Forwarder done")
|
f.logger.Debug("Forwarder done")
|
||||||
return
|
return
|
||||||
case <-time.After(f.avgInterval):
|
case <-timer.C:
|
||||||
f.exec()
|
f.exec()
|
||||||
|
timer.Reset(f.avgInterval)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
Loading…
Reference in New Issue
Block a user