Description
The real implementation of ticker func looks like this:
func (t *realContextTicker) Wait(_ ...string) error {
return <-t.err
}
func (t *realContextTicker) run() {
defer t.tkr.Stop()
for {
select {
case <-t.ctx.Done():
t.err <- t.ctx.Err()
return
case <-t.tkr.C:
err := t.f()
if err != nil {
t.err <- err
return
}
}
}
}
One property of this construction is that Wait()
cannot return while t.f()
is in progress, even if the context is done.
The mock ticker function doesn't share this property, and Wait()
will return immediately on context done.