MCPcopy
hub / github.com/tailscale/tailscale / newClockInternal

Function newClockInternal

tstest/clock.go:65–82  ·  view source on GitHub ↗

newClockInternal creates a Clock with the specified settings and allows specifying a non-standard realTimeClock.

(co ClockOpts, rtClock tstime.Clock)

Source from the content-addressed store, hash-verified

63// newClockInternal creates a Clock with the specified settings and allows
64// specifying a non-standard realTimeClock.
65func newClockInternal(co ClockOpts, rtClock tstime.Clock) *Clock {
66 if !co.FollowRealTime && rtClock != nil {
67 panic("rtClock can only be set with FollowRealTime enabled")
68 }
69
70 if co.FollowRealTime && rtClock == nil {
71 rtClock = new(tstime.StdClock)
72 }
73
74 c := &Clock{
75 start: co.Start,
76 realTimeClock: rtClock,
77 step: co.Step,
78 timerChannelSize: co.TimerChannelSize,
79 }
80 c.init() // init now to capture the current time when co.Start.IsZero()
81 return c
82}
83
84// Clock is a testing clock that advances every time its Now method is
85// called, beginning at its start time. If no start time is specified using

Callers 5

TestSingleTickerFunction · 0.85
TestSingleTimerFunction · 0.85
TestClockFollowRealTimeFunction · 0.85
TestAfterFuncFunction · 0.85
NewClockFunction · 0.85

Calls 1

initMethod · 0.95

Tested by 4

TestSingleTickerFunction · 0.68
TestSingleTimerFunction · 0.68
TestClockFollowRealTimeFunction · 0.68
TestAfterFuncFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…