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 |
+ |
// 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 |
} |