newClockInternal creates a Clock with the specified settings and allows specifying a non-standard realTimeClock.
(co ClockOpts, rtClock tstime.Clock)
| 63 | // newClockInternal creates a Clock with the specified settings and allows |
| 64 | // specifying a non-standard realTimeClock. |
| 65 | func 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 |
searching dependent graphs…