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

Unified Diff: appengine/memlock/memlock.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 | « no previous file | common/clock/clock.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/memlock/memlock.go
diff --git a/appengine/memlock/memlock.go b/appengine/memlock/memlock.go
index b0f14f5c663f5b579f1f53989469ccdd6522799d..7eefeb0d0d1bc495bafc116ac2bfa754cc2c66d0 100644
--- a/appengine/memlock/memlock.go
+++ b/appengine/memlock/memlock.go
@@ -152,12 +152,9 @@ func TryWithLock(ctx context.Context, key, clientID string, f func(context.Conte
close(finished)
}()
- checkLoop:
for {
- select {
- case <-subCtx.Done():
- break checkLoop
- case <-clock.Get(ctx).After(delay):
+ if (<-clock.After(subCtx, delay)).Err != nil {
+ break
}
if !checkAnd(refresh) {
log.Warningf("lost lock: %s", err)
« no previous file with comments | « no previous file | common/clock/clock.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698