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

Unified Diff: common/clock/clockcontext.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 | « common/clock/clock.go ('k') | common/clock/clockcontext_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: common/clock/clockcontext.go
diff --git a/common/clock/clockcontext.go b/common/clock/clockcontext.go
index 979f2fc0588d02a29fc808553ff43742c9dbb640..1b9df12e35e83e0a6be23c9ece273f3e7f04fafd 100644
--- a/common/clock/clockcontext.go
+++ b/common/clock/clockcontext.go
@@ -71,11 +71,8 @@ func WithDeadline(parent context.Context, deadline time.Time) (context.Context,
// Invoke our cancelFunc after the specified time.
go func() {
- select {
- case <-c.Done():
- break
-
- case <-After(c, d):
+ if ar := <-After(c, d); ar.Err == nil {
+ // Timer expired naturally.
c.setError(context.DeadlineExceeded)
cancelFunc()
}
« no previous file with comments | « common/clock/clock.go ('k') | common/clock/clockcontext_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698