MCPcopy Index your code
hub / github.com/tailscale/tailscale / NewTimer

Method NewTimer

tstest/clock.go:278–292  ·  view source on GitHub ↗

NewTimer returns a Timer that uses this Clock for accessing the current time.

(d time.Duration)

Source from the content-addressed store, hash-verified

276// NewTimer returns a Timer that uses this Clock for accessing the current
277// time.
278func (c *Clock) NewTimer(d time.Duration) (tstime.TimerController, <-chan time.Time) {
279 c.init()
280 rt := c.maybeGetRealTime()
281
282 c.mu.Lock()
283 defer c.mu.Unlock()
284
285 c.advanceLocked(rt, 0)
286 t := &Timer{
287 nextTrigger: c.present.Add(d),
288 em: &c.events,
289 }
290 t.init(c.timerChannelSize, nil)
291 return t, t.C
292}
293
294// AfterFunc returns a Timer that calls f when it fires, using this Clock for
295// accessing the current time.

Callers

nothing calls this directly

Implementers 3

DefaultClocktstime/tstime.go
StdClocktstime/tstime.go
Clocktstest/clock.go

Calls 7

initMethod · 0.95
maybeGetRealTimeMethod · 0.95
advanceLockedMethod · 0.95
initMethod · 0.95
LockMethod · 0.65
UnlockMethod · 0.65
AddMethod · 0.65

Tested by

no test coverage detected