Chromium Code Reviews| Index: common/clock/clock.go |
| diff --git a/common/clock/clock.go b/common/clock/clock.go |
| index 5fe5dc24b01600f5ce5f233af912b9416d2be92c..4ebb95d1a175923f0cf77e56f8a808a84d8454d8 100644 |
| --- a/common/clock/clock.go |
| +++ b/common/clock/clock.go |
| @@ -6,6 +6,8 @@ package clock |
| import ( |
| "time" |
| + |
| + "golang.org/x/net/context" |
| ) |
| // Clock is an interface to system time. |
| @@ -16,10 +18,21 @@ import ( |
| type Clock interface { |
| // Returns the current time (see time.Now). |
| Now() time.Time |
| - // Sleeps the current goroutine (see time.Sleep) |
| - Sleep(time.Duration) |
| + |
| + // Sleeps the current goroutine (see time.Sleep). |
| + // |
| + // If the supplied Context is canceled prior to the specified duration, |
| + // CancelSleep will return the Context's error. If the sleep completes |
| + // naturally, it will return nil. |
|
iannucci
2016/02/10 22:30:28
CancelSleep comment
dnj (Google)
2016/02/11 01:26:54
Done.
|
| + Sleep(context.Context, time.Duration) error |
| + |
| // Creates a new Timer instance, bound to this Clock. |
| - NewTimer() Timer |
| + // |
| + // If the supplied Context is canceled, the timer will expire immediately. |
| + NewTimer(c context.Context) Timer |
| + |
| // Waits a duration, then sends the current time over the returned channel. |
| - After(time.Duration) <-chan time.Time |
| + // |
| + // If the supplied Context is canceled, the timer will expire immediately. |
| + After(context.Context, time.Duration) <-chan TimerResult |
| } |