Defer stop ticker

This commit is contained in:
CallanTaylor 2019-11-19 15:14:49 +13:00
parent 450d163040
commit 58d1eef502

View file

@ -118,6 +118,7 @@ func (t *TaskManager) NewTickerTask(duration time.Duration, before func(stop cha
before(stop) before(stop)
} }
tickChan := time.NewTicker(duration) tickChan := time.NewTicker(duration)
defer tickChan.Stop()
// calling f first so that we're not waiting for the first tick // calling f first so that we're not waiting for the first tick
f(stop, notifyStopped) f(stop, notifyStopped)
for { for {