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

Side by Side Diff: appengine/memlock/memlock.go

Issue 1679023005: Add Context cancellation to clock. (Closed) Base URL: https://github.com/luci/luci-go@master
Patch Set: Much more invasive, cancel by default, remove meter package. 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 unified diff | Download patch
« no previous file with comments | « no previous file | common/clock/clock.go » ('j') | common/clock/clockcontext_test.go » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Package memlock allows multiple appengine handlers to coordinate best-effort 5 // Package memlock allows multiple appengine handlers to coordinate best-effort
6 // mutual execution via memcache. "best-effort" here means "best-effort"... 6 // mutual execution via memcache. "best-effort" here means "best-effort"...
7 // memcache is not reliable. However, colliding on memcache is a lot cheaper 7 // memcache is not reliable. However, colliding on memcache is a lot cheaper
8 // than, for example, colliding with datastore transactions. 8 // than, for example, colliding with datastore transactions.
9 package memlock 9 package memlock
10 10
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 defer func() { 150 defer func() {
151 cancelFunc() 151 cancelFunc()
152 close(finished) 152 close(finished)
153 }() 153 }()
154 154
155 checkLoop: 155 checkLoop:
156 for { 156 for {
157 select { 157 select {
158 case <-subCtx.Done(): 158 case <-subCtx.Done():
159 break checkLoop 159 break checkLoop
160 » » » case <-clock.Get(ctx).After(delay): 160 » » » case <-clock.Get(ctx).After(ctx, delay):
161 } 161 }
162 if !checkAnd(refresh) { 162 if !checkAnd(refresh) {
163 log.Warningf("lost lock: %s", err) 163 log.Warningf("lost lock: %s", err)
164 return 164 return
165 } 165 }
166 } 166 }
167 167
168 if testStopCB != nil { 168 if testStopCB != nil {
169 testStopCB() 169 testStopCB()
170 } 170 }
171 checkAnd(release) 171 checkAnd(release)
172 }() 172 }()
173 173
174 return f(subCtx) 174 return f(subCtx)
175 } 175 }
OLDNEW
« no previous file with comments | « no previous file | common/clock/clock.go » ('j') | common/clock/clockcontext_test.go » ('J')

Powered by Google App Engine
This is Rietveld 408576698