| Index: common/clock/clock.go
|
| diff --git a/common/clock/clock.go b/common/clock/clock.go
|
| index 5fe5dc24b01600f5ce5f233af912b9416d2be92c..394c2c738e916a4a627859a1b3d1e2e24e74559d 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,34 @@ 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.
|
| + 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 AfterResult
|
| +}
|
| +
|
| +// AfterResult is the result fo a timer operation.
|
| +//
|
| +// If the timer operation completed successfully, the embedded time.Time will be
|
| +// set to the time when the timer triggered. If the timer was prematurely
|
| +// terminated, Err will be non-nil.
|
| +type AfterResult struct {
|
| + time.Time
|
| +
|
| + // Err, if not nil, indicates that After did not finish naturally and contains
|
| + // the reason why.
|
| + Err error
|
| }
|
|
|