Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(225)

Unified Diff: common/clock/clock.go

Issue 1679023005: Add Context cancellation to clock. (Closed) Base URL: https://github.com/luci/luci-go@master
Patch Set: Actually upload the patch. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « appengine/memlock/memlock.go ('k') | common/clock/clockcontext.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
}
« no previous file with comments | « appengine/memlock/memlock.go ('k') | common/clock/clockcontext.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698