MCPcopy
hub / github.com/tailscale/tailscale / Clock

Struct Clock

tstest/clock.go:88–119  ·  view source on GitHub ↗

Clock is a testing clock that advances every time its Now method is called, beginning at its start time. If no start time is specified using ClockBuilder, an arbitrary start time will be selected when the Clock is created and can be retrieved by calling Clock.Start().

Source from the content-addressed store, hash-verified

86// ClockBuilder, an arbitrary start time will be selected when the Clock is
87// created and can be retrieved by calling Clock.Start().
88type Clock struct {
89 // start is the first value returned by Now. It must not be modified after
90 // init is called.
91 start time.Time
92
93 // realTimeClock, if not nil, indicates that the Clock shall move forward
94 // according to realTimeClock + the accumulated calls to Advance. This can
95 // make writing tests easier that require some control over the clock but do
96 // not need exact control over the clock. While step can also be used for
97 // this purpose, it is harder to control how quickly time moves using step.
98 realTimeClock tstime.Clock
99
100 initOnce sync.Once
101 mu sync.Mutex
102
103 // step is how much to advance with each Now call.
104 step time.Duration
105 // present is the last value returned by Now (and will be returned again by
106 // PeekNow).
107 present time.Time
108 // realTime is the time from realTimeClock corresponding to the current
109 // value of present.
110 realTime time.Time
111 // skipStep indicates that the next call to Now should not add step to
112 // present. This occurs after initialization and after Advance.
113 skipStep bool
114 // timerChannelSize is the buffer size to use for channels created by
115 // NewTimer and NewTicker.
116 timerChannelSize int
117
118 events eventManager
119}
120
121func (c *Clock) init() {
122 c.initOnce.Do(func() {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected