-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathinterface.go
More file actions
36 lines (31 loc) · 967 Bytes
/
interface.go
File metadata and controls
36 lines (31 loc) · 967 Bytes
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
31
32
33
34
35
36
package abtime
import (
"context"
"time"
)
// Ticker defines an interface for the functions that return *time.Ticker
// in the original Time module.
type Ticker interface {
Channel() <-chan time.Time
Reset(time.Duration)
Stop()
}
// Timer defines an interface for the functions that return *time.Timer
// in the original Time module.
type Timer interface {
Stop() bool
Reset(time.Duration) bool
Channel() <-chan time.Time
}
// The AbstractTime interface abstracts the time module into an interface.
type AbstractTime interface {
Now() time.Time
After(time.Duration, int) <-chan time.Time
Sleep(time.Duration, int)
Tick(time.Duration, int) <-chan time.Time
NewTicker(time.Duration, int) Ticker
AfterFunc(time.Duration, func(), int) Timer
NewTimer(time.Duration, int) Timer
WithDeadline(context.Context, time.Time, int) (context.Context, context.CancelFunc)
WithTimeout(context.Context, time.Duration, int) (context.Context, context.CancelFunc)
}