MCPcopy Create free account
hub / github.com/tailscale/tailscale / init

Method init

tstest/clock.go:629–646  ·  view source on GitHub ↗
(channelSize int, afterFunc func())

Source from the content-addressed store, hash-verified

627}
628
629func (t *Timer) init(channelSize int, afterFunc func()) {
630 if channelSize <= 0 {
631 panic("ticker channel size must be non-negative")
632 }
633 c := make(chan time.Time, channelSize)
634 t.C = c
635 if afterFunc == nil {
636 t.f = func(curTime time.Time) {
637 select {
638 case c <- curTime:
639 default:
640 }
641 }
642 } else {
643 t.f = func(_ time.Time) { afterFunc() }
644 }
645 t.em.Reschedule(t, t.nextTrigger)
646}
647
648// Fire triggers the ticker. curTime is the timestamp to write to the channel.
649// The next trigger time for the ticker is updated to the last computed trigger

Callers 2

NewTimerMethod · 0.95
AfterFuncMethod · 0.95

Calls 1

RescheduleMethod · 0.80

Tested by

no test coverage detected