Chromium Code Reviews| Index: common/clock/clock.go |
| diff --git a/common/clock/clock.go b/common/clock/clock.go |
| index 5fe5dc24b01600f5ce5f233af912b9416d2be92c..c07b46f6ecdec7c925e9764bda2ac232d21eb1e9 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, |
| + // Sleep will return the Context's error. If the sleep completes naturally, |
| + // it will return nil. |
| + Sleep(context.Context, time.Duration) error |
|
iannucci
2016/02/11 02:15:33
Vadim suggests (and I agree) that this should prob
iannucci
2016/02/11 02:16:35
Which, I realize, sounds silly considering that yo
dnj (Google)
2016/02/11 17:22:37
My initial reaction is that I don't like the idea
|
| + |
| // 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 |
| } |