| OLD | NEW |
| 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 Loading... |
| 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 } |
| OLD | NEW |