| 1 |
package clock |
| 2 |
|
| 3 |
import "time" |
| 4 |
|
| 5 |
type systemTime struct{} |
| 6 |
|
| 7 |
func (st *systemTime) Now() time.Time { |
| 8 |
return time.Now() |
| 9 |
} |
| 10 |
|
| 11 |
func (st *systemTime) Sleep(d time.Duration) { |
| 12 |
time.Sleep(d) |
| 13 |
} |
| 14 |
|
| 15 |
func (st *systemTime) After(d time.Duration) <-chan time.Time { |
| 16 |
return time.After(d) |
| 17 |
} |
| 18 |
|
| 19 |
type systemTimer struct { |
| 20 |
t *time.Timer |
| 21 |
} |
| 22 |
|
| 23 |
func (st *systemTime) NewTimer(d time.Duration) Timer { |
| 24 |
t := time.NewTimer(d) |
| 25 |
return &systemTimer{t} |
| 26 |
} |
| 27 |
|
| 28 |
func (st *systemTime) AfterFunc(d time.Duration, f func()) Timer { |
| 29 |
t := time.AfterFunc(d, f) |
| 30 |
return &systemTimer{t} |
| 31 |
} |
| 32 |
|
| 33 |
func (t *systemTimer) C() <-chan time.Time { |
| 34 |
return t.t.C |
| 35 |
} |
| 36 |
|
| 37 |
func (t *systemTimer) Stop() bool { |
| 38 |
return t.t.Stop() |
| 39 |
} |
| 40 |
|
| 41 |
func (t *systemTimer) Reset(d time.Duration) bool { |
| 42 |
return t.t.Reset(d) |
| 43 |
} |
| 44 |
|
| 45 |
type systemTicker struct { |
| 46 |
t *time.Ticker |
| 47 |
} |
| 48 |
|
| 49 |
func (t *systemTicker) C() <-chan time.Time { |
| 50 |
return t.t.C |
| 51 |
} |
| 52 |
|
| 53 |
func (t *systemTicker) Stop() { |
| 54 |
t.t.Stop() |
| 55 |
} |
| 56 |
|
| 57 |
func (st *systemTime) NewTicker(d time.Duration) Ticker { |
| 58 |
t := time.NewTicker(d) |
| 59 |
return &systemTicker{t} |
| 60 |
} |
| 61 |
|
| 62 |
func (st *systemTime) Tick(d time.Duration) <-chan time.Time { |
| 63 |
return time.Tick(d) |
| 64 |
} |
| 65 |
|
| 66 |
func (st *systemTime) Wait4Scheduled(count int, timeout time.Duration) bool { |
| 67 |
panic("Not supported") |
| 68 |
} |