// AfterFunc waits for the duration to elapse and then executes a function.
// A Timer is returned that can be stopped.
327280
func (m *Mock) AfterFunc(d time.Duration, f func()) *Timer {
	t := m.Timer(d)
	go func() {
		<-t.c
		f()
	}()
	nap()
	return t
}
110112
func afterBetween(min time.Duration, max time.Duration) <-chan time.Time {
	rand := rand.New(rand.NewSource(time.Now().UnixNano()))
	d, delta := min, (max - min)
	if delta > 0 {
		d += time.Duration(rand.Int63n(int64(delta)))
	}
	return time.After(d)
}
1088087
func AfterDelay(d time.Duration) SendDecorator {
	return func(s Sender) Sender {
		return SenderFunc(func(r *http.Request) (*http.Response, error) {
			if !DelayForBackoff(d, 0, r.Context().Done()) {
				return nil, fmt.Errorf("autorest: AfterDelay canceled before full delay")
			}
			return s.Do(r)
		})
	}
}
756599
func (c *Cron) AddFunc(spec string, cmd func()) error {
	return c.AddJob(spec, FuncJob(cmd))
}
657507
func (worker *Worker) AddFunc(funcname string,
	f JobFunc, timeout uint32) (err error) {
	worker.Lock()
	defer worker.Unlock()
	if _, ok := worker.funcs[funcname]; ok {
		return fmt.Errorf("The function already exists: %s", funcname)
	}
	worker.funcs[funcname] = &jobFunc{f: f, timeout: timeout}
	if worker.running {
		worker.addFunc(funcname, timeout)
	}
	return
}
731149
func AfterFunc(d time.Duration, f func()) Timer {
	return provider.AfterFunc(d, f)
}
251536
func wrapFunc(fn Func) FuncCtx {
	if fn == nil {
		return nil // be sure not to wrap a bad function.
	}
	return func(ctx context.Context, fl FieldLevel) bool {
		return fn(fl)
	}
}
574516
func (g *Group) ReturnFunc(f func(*Group)) *Statement {
	s := ReturnFunc(f)
	g.items = append(g.items, s)
	return s
}
169737
func ReturnAfter(runtimeLimit time.Duration, callback func()) bool {
	timeout := time.NewTimer(runtimeLimit)
	callOk := make(chan bool)

	go func() {
		callback()
		timeout.Stop()
		callOk <- true
	}()

	select {
	case <-timeout.C:
		return false

	case <-callOk:
		return true
	}
}
630533
func afterCreateCallback(scope *Scope) {
	if !scope.HasError() {
		scope.CallMethod("AfterCreate")
	}
	if !scope.HasError() {
		scope.CallMethod("AfterSave")
	}
}
307959
func (r *Response) After(fn func()) {
	r.afterFuncs = append(r.afterFuncs, fn)
}
727066
func (ctx *Context) After(hook func()) {
	if ctx.Res.ended.isTrue() { // should not add afterHooks if ctx.Res.ended
		panic(Err.WithMsg(`can't add "after hook" after middleware process ended`))
	}
	ctx.Res.afterHooks = append(ctx.Res.afterHooks, hook)
}
155950
func (task *TCPListenerTask) StopFunc(perform func()) {
	task.LoopTask.StopFunc(func() {
		task.stop()
		perform()
	})
}
1138471
func WaitFunc(wg *sync.WaitGroup, wait func()) StopChan {
	return WaitErrFunc(wg, func() error {
		wait()
		return nil
	})
}
823393
func (c Chain) ThenFunc(fn http.HandlerFunc) http.Handler {
	if fn == nil {
		return c.Then(nil)
	}
	return c.Then(fn)
}
1203610
func (m *Method) FinalFunc(f FinalFunc) *Method {
	m.finalFuncs = append(m.finalFuncs, f)
	return m
}
1153826
func (RealClock) After(d time.Duration) <-chan time.Time {
	return time.After(d)
}