{"modulePath":"github.com/UnityTech/client-go","version":"v3.0.0+incompatible","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package clock\n\n## Types\n\n```go\ntype Clock interface {\n\tNow() time.Time\n\tSince(time.Time) time.Duration\n\tAfter(d time.Duration) \u003c-chan time.Time\n\tNewTimer(d time.Duration) Timer\n\tSleep(d time.Duration)\n\tTick(d time.Duration) \u003c-chan time.Time\n}\n```\nClock allows for injecting fake or real clocks into code that needs to do arbitrary things based on time.\n\n```go\ntype FakeClock struct {\n\t// contains filtered or unexported fields\n}\n```\nFakeClock implements Clock, but returns an arbitrary time.\n\n```go\nfunc NewFakeClock(t time.Time) *FakeClock\n```\n\n```go\nfunc (f *FakeClock) After(d time.Duration) \u003c-chan time.Time\n```\nFake version of time.After(d).\n\n```go\nfunc (f *FakeClock) HasWaiters() bool\n```\nReturns true if After has been called on f but not yet satisfied (so you can write race-free tests).\n\n```go\nfunc (f *FakeClock) NewTimer(d time.Duration) Timer\n```\nFake version of time.NewTimer(d).\n\n```go\nfunc (f *FakeClock) Now() time.Time\n```\nNow returns f's time.\n\n```go\nfunc (f *FakeClock) SetTime(t time.Time)\n```\nSets the time.\n\n```go\nfunc (f *FakeClock) Since(ts time.Time) time.Duration\n```\nSince returns time since the time in f.\n\n```go\nfunc (f *FakeClock) Sleep(d time.Duration)\n```\n\n```go\nfunc (f *FakeClock) Step(d time.Duration)\n```\nMove clock by Duration, notify anyone that's called After, Tick, or NewTimer\n\n```go\nfunc (f *FakeClock) Tick(d time.Duration) \u003c-chan time.Time\n```\n\n```go\ntype IntervalClock struct {\n\tTime     time.Time\n\tDuration time.Duration\n}\n```\nIntervalClock implements Clock, but each invocation of Now steps the clock forward the specified duration\n\n```go\nfunc (*IntervalClock) After(d time.Duration) \u003c-chan time.Time\n```\nUnimplemented, will panic. TODO: make interval clock use FakeClock so this can be implemented.\n\n```go\nfunc (*IntervalClock) NewTimer(d time.Duration) Timer\n```\nUnimplemented, will panic. TODO: make interval clock use FakeClock so this can be implemented.\n\n```go\nfunc (i *IntervalClock) Now() time.Time\n```\nNow returns i's time.\n\n```go\nfunc (i *IntervalClock) Since(ts time.Time) time.Duration\n```\nSince returns time since the time in i.\n\n```go\nfunc (*IntervalClock) Sleep(d time.Duration)\n```\n\n```go\nfunc (*IntervalClock) Tick(d time.Duration) \u003c-chan time.Time\n```\nUnimplemented, will panic. TODO: make interval clock use FakeClock so this can be implemented.\n\n```go\ntype RealClock struct{}\n```\nRealClock really calls time.Now()\n\n```go\nfunc (RealClock) After(d time.Duration) \u003c-chan time.Time\n```\nSame as time.After(d).\n\n```go\nfunc (RealClock) NewTimer(d time.Duration) Timer\n```\n\n```go\nfunc (RealClock) Now() time.Time\n```\nNow returns the current time.\n\n```go\nfunc (RealClock) Since(ts time.Time) time.Duration\n```\nSince returns time since the specified timestamp.\n\n```go\nfunc (RealClock) Sleep(d time.Duration)\n```\n\n```go\nfunc (RealClock) Tick(d time.Duration) \u003c-chan time.Time\n```\n\n```go\ntype Timer interface {\n\tC() \u003c-chan time.Time\n\tStop() bool\n\tReset(d time.Duration) bool\n}\n```\nTimer allows for injecting fake or real timers into code that needs to do arbitrary things based on time.\n\n","path":"github.com/UnityTech/client-go/util/clock","name":"clock","synopsis":"","isRedistributable":true}
