-
Notifications
You must be signed in to change notification settings - Fork 0
/
xtime_default.go
30 lines (26 loc) · 1.34 KB
/
xtime_default.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package xtime
import (
"context"
"time"
)
var defaultMock = newMockNotStart(newDefaultOptions())
func getDefaultMock() Mock {
defaultMock.start()
return defaultMock
}
func ApplyOption(opt ...Option) { getDefaultMock().ApplyOption(opt...) }
func Now() time.Time { return getDefaultMock().Now() }
func Since(t time.Time) time.Duration { return getDefaultMock().Since(t) }
func Until(t time.Time) time.Duration { return getDefaultMock().Until(t) }
func Sleep(d time.Duration) { getDefaultMock().Sleep(d) }
func Tick(d time.Duration) <-chan time.Time { return getDefaultMock().Tick(d) }
func After(d time.Duration) <-chan time.Time { return getDefaultMock().After(d) }
func AfterFunc(d time.Duration, f func()) *MockTimer { return getDefaultMock().AfterFunc(d, f) }
func Timer(d time.Duration) *MockTimer { return getDefaultMock().Timer(d) }
func NewTicker(d time.Duration) *MockTicker { return getDefaultMock().NewTicker(d) }
func WithDeadline(parent context.Context, d time.Time) (context.Context, context.CancelFunc) {
return getDefaultMock().WithDeadline(parent, d)
}
func WithTimeout(parent context.Context, t time.Duration) (context.Context, context.CancelFunc) {
return getDefaultMock().WithTimeout(parent, t)
}