-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
deduplicate code in build tags that isn't using mutex in either
- Loading branch information
1 parent
0ed8e0c
commit 0c59bbe
Showing
3 changed files
with
43 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package clock | ||
|
||
import "time" | ||
|
||
// Timer see time.Timer. | ||
type Timer interface { | ||
C() <-chan time.Time | ||
Stop() bool | ||
Reset(d time.Duration) bool | ||
} | ||
|
||
// Ticker see time.Ticker. | ||
type Ticker interface { | ||
C() <-chan time.Time | ||
Stop() | ||
} | ||
|
||
// NewStoppedTimer returns a stopped timer. Call Reset to get it ticking. | ||
func NewStoppedTimer() Timer { | ||
t := NewTimer(42 * time.Hour) | ||
t.Stop() | ||
return t | ||
} | ||
|
||
// Clock is an interface that mimics the one of the SDK time package. | ||
type Clock interface { | ||
Now() time.Time | ||
Sleep(d time.Duration) | ||
After(d time.Duration) <-chan time.Time | ||
NewTimer(d time.Duration) Timer | ||
AfterFunc(d time.Duration, f func()) Timer | ||
NewTicker(d time.Duration) Ticker | ||
Tick(d time.Duration) <-chan time.Time | ||
Wait4Scheduled(n int, timeout time.Duration) bool | ||
} |