t.Log.Info("returned from function, closing notifyStopped")
close(notifyStopped)
}()
@ -99,7 +102,8 @@ func (t *Task) Stop() {
ift.stopped{
return
}
close(t.stop)
t.cancel()
t.Log.Info("closed stop channel, waiting for notifyStopped message")
<-t.notifyStopped
t.Log.Info("received notifystopped message")
@ -109,28 +113,28 @@ func (t *Task) Stop() {
// NewTickerTask is a convenience function for making a new task that repeats some action once per e.g. second
// the before function gets called after the lock is obtained, but before the ticker starts.
// if you handle a message on the stop channel in f() you need to send a message on the notifyStopped channel because returning is not sufficient. Here, unlike in a regular task, simply returning means we're now going to wait till the next tick to run again.