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

Issue 1679023005: Add Context cancellation to clock. (Closed)

Created:
4 years, 10 months ago by dnj
Modified:
4 years, 10 months ago
CC:
chromium-reviews, infra-reviews+luci-go_chromium.org, andrew.wang, todd, tandrii+luci-go_chromium.org, M-A Ruel
Base URL:
https://github.com/luci/luci-go@master
Target Ref:
refs/heads/master
Project:
luci-go
Visibility:
Public.

Description

Add Context cancellation to clock. Add Context cancellation to the clock package methods. Effectively this makes it so that Clock methods (Sleep, After, Timer) will terminate early if their supplied Context is canceled. Update other packages to accommodate this. This update includes: - Update "ackbuffer" to not use the "meter" package. - Add a "TakeAll" method to parallel's Semaphore, which takes all instances of the semaphore. This is effectively a Join on the Semaphore. - Remove the "meter" package. This is easier than fixing its tests, and (with "ackbuffer" out of the way) all of the uses that originally inspired it have switched to more custom methods. R=iannucci@chromium.org, vadimsh@chromium.org BUG= Committed: https://github.com/luci/luci-go/commit/86e9094387fea7e47efe06fba090fe3118f66650

Patch Set 1 #

Total comments: 2

Patch Set 2 : Much more invasive, cancel by default, remove meter package. #

Total comments: 5

Patch Set 3 : Cleanup memlock, restore old determinism, better name. #

Total comments: 2

Patch Set 4 : More test coverage, cleanup, consolidation. #

Total comments: 38

Patch Set 5 : Updated from comments, conformant to time interface. #

Total comments: 8

Patch Set 6 : Actually upload the patch. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+837 lines, -823 lines) Patch
M appengine/memlock/memlock.go View 1 2 1 chunk +2 lines, -5 lines 0 comments Download
M common/clock/clock.go View 1 2 3 4 2 chunks +17 lines, -4 lines 0 comments Download
M common/clock/clockcontext.go View 1 1 chunk +2 lines, -5 lines 0 comments Download
M common/clock/clockcontext_test.go View 1 2 1 chunk +97 lines, -79 lines 0 comments Download
M common/clock/external.go View 1 2 3 4 5 3 chunks +7 lines, -10 lines 0 comments Download
M common/clock/external_test.go View 1 2 3 chunks +9 lines, -8 lines 0 comments Download
M common/clock/systemclock.go View 1 2 3 4 2 chunks +11 lines, -6 lines 0 comments Download
A common/clock/systemclock_test.go View 1 2 3 4 1 chunk +47 lines, -0 lines 0 comments Download
M common/clock/systemtimer.go View 1 2 3 4 1 chunk +60 lines, -12 lines 0 comments Download
M common/clock/systemtimer_test.go View 1 2 3 4 3 chunks +54 lines, -19 lines 0 comments Download
A common/clock/tags.go View 1 2 3 4 5 1 chunk +28 lines, -0 lines 0 comments Download
A common/clock/tags_test.go View 1 1 chunk +39 lines, -0 lines 0 comments Download
M common/clock/testclock/testclock.go View 1 2 3 4 6 chunks +46 lines, -29 lines 0 comments Download
M common/clock/testclock/testclock_test.go View 1 2 3 4 2 chunks +28 lines, -13 lines 0 comments Download
M common/clock/testclock/testtimer.go View 1 2 3 4 3 chunks +67 lines, -20 lines 0 comments Download
M common/clock/testclock/testtimer_test.go View 1 2 3 4 4 chunks +163 lines, -17 lines 0 comments Download
M common/clock/timer.go View 1 2 3 4 1 chunk +25 lines, -5 lines 0 comments Download
M common/gcloud/pubsub/ackbuffer/ackbuffer.go View 1 2 3 4 4 chunks +78 lines, -37 lines 0 comments Download
M common/gcloud/pubsub/ackbuffer/ackbuffer_test.go View 1 5 chunks +48 lines, -29 lines 0 comments Download
M common/gcloud/pubsub/subscriber/subscriber.go View 1 1 chunk +1 line, -14 lines 0 comments Download
D common/meter/config.go View 1 1 chunk +0 lines, -59 lines 0 comments Download
D common/meter/config_test.go View 1 1 chunk +0 lines, -33 lines 0 comments Download
D common/meter/doc.go View 1 1 chunk +0 lines, -10 lines 0 comments Download
D common/meter/meter.go View 1 1 chunk +0 lines, -213 lines 0 comments Download
D common/meter/meter_test.go View 1 1 chunk +0 lines, -196 lines 0 comments Download
M common/parallel/semaphore.go View 1 1 chunk +8 lines, -0 lines 0 comments Download

Messages

Total messages: 23 (5 generated)
dnj
4 years, 10 months ago (2016-02-09 19:54:37 UTC) #1
iannucci
https://codereview.chromium.org/1679023005/diff/1/common/clock/cancelSleep.go File common/clock/cancelSleep.go (right): https://codereview.chromium.org/1679023005/diff/1/common/clock/cancelSleep.go#newcode18 common/clock/cancelSleep.go:18: func CancelSleep(c context.Context, d time.Duration) error { (discussed offline) ...
4 years, 10 months ago (2016-02-09 20:41:10 UTC) #2
Vadim Sh.
https://codereview.chromium.org/1679023005/diff/1/common/clock/cancelSleep.go File common/clock/cancelSleep.go (right): https://codereview.chromium.org/1679023005/diff/1/common/clock/cancelSleep.go#newcode18 common/clock/cancelSleep.go:18: func CancelSleep(c context.Context, d time.Duration) error { On 2016/02/09 ...
4 years, 10 months ago (2016-02-09 21:11:37 UTC) #3
dnj (Google)
On 2016/02/09 21:11:37, Vadim Sh. wrote: > https://codereview.chromium.org/1679023005/diff/1/common/clock/cancelSleep.go > File common/clock/cancelSleep.go (right): > > https://codereview.chromium.org/1679023005/diff/1/common/clock/cancelSleep.go#newcode18 ...
4 years, 10 months ago (2016-02-10 01:24:14 UTC) #4
dnj (Google)
PTAL, updated based on discussion. Grew a bit, but for the better IMO. Have annotations. ...
4 years, 10 months ago (2016-02-10 03:19:04 UTC) #7
dnj (Google)
https://codereview.chromium.org/1679023005/diff/40001/appengine/memlock/memlock.go File appengine/memlock/memlock.go (right): https://codereview.chromium.org/1679023005/diff/40001/appengine/memlock/memlock.go#newcode156 appengine/memlock/memlock.go:156: if (<-clock.After(subCtx, delay)).Err != nil { Nice, eh? https://codereview.chromium.org/1679023005/diff/40001/common/clock/testclock/testclock.go ...
4 years, 10 months ago (2016-02-10 03:40:09 UTC) #9
Vadim Sh.
Adding optional functionality that forced on you mandatory into low level functions like Sleep is ...
4 years, 10 months ago (2016-02-10 19:39:16 UTC) #10
iannucci
looks pretty good to me! Some thingies tho https://codereview.chromium.org/1679023005/diff/60001/common/clock/clock.go File common/clock/clock.go (right): https://codereview.chromium.org/1679023005/diff/60001/common/clock/clock.go#newcode26 common/clock/clock.go:26: // ...
4 years, 10 months ago (2016-02-10 22:30:28 UTC) #11
dnj (Google)
Thanks for the review! RE vadimsh@: I hear 'ya. I originally wanted this to be ...
4 years, 10 months ago (2016-02-11 01:26:55 UTC) #12
iannucci
https://codereview.chromium.org/1679023005/diff/80001/common/clock/clock.go File common/clock/clock.go (right): https://codereview.chromium.org/1679023005/diff/80001/common/clock/clock.go#newcode27 common/clock/clock.go:27: Sleep(context.Context, time.Duration) error Vadim suggests (and I agree) that ...
4 years, 10 months ago (2016-02-11 02:15:33 UTC) #13
iannucci
https://codereview.chromium.org/1679023005/diff/80001/common/clock/clock.go File common/clock/clock.go (right): https://codereview.chromium.org/1679023005/diff/80001/common/clock/clock.go#newcode27 common/clock/clock.go:27: Sleep(context.Context, time.Duration) error On 2016/02/11 02:15:33, iannucci wrote: > ...
4 years, 10 months ago (2016-02-11 02:16:35 UTC) #14
iannucci
https://codereview.chromium.org/1679023005/diff/80001/common/clock/systemclock_test.go File common/clock/systemclock_test.go (right): https://codereview.chromium.org/1679023005/diff/80001/common/clock/systemclock_test.go#newcode24 common/clock/systemclock_test.go:24: const timeBase = 60 * time.Millisecond Note that runtime.Gosched ...
4 years, 10 months ago (2016-02-11 02:24:04 UTC) #15
dnj (Google)
Updated w/ some thoughts. https://codereview.chromium.org/1679023005/diff/80001/common/clock/clock.go File common/clock/clock.go (right): https://codereview.chromium.org/1679023005/diff/80001/common/clock/clock.go#newcode27 common/clock/clock.go:27: Sleep(context.Context, time.Duration) error On 2016/02/11 ...
4 years, 10 months ago (2016-02-11 17:22:37 UTC) #16
iannucci
https://codereview.chromium.org/1679023005/diff/80001/common/clock/tags.go File common/clock/tags.go (right): https://codereview.chromium.org/1679023005/diff/80001/common/clock/tags.go#newcode11 common/clock/tags.go:11: var clockTagKey = &[]string{"clock-tag"} On 2016/02/11 17:22:37, dnj (Google) ...
4 years, 10 months ago (2016-02-12 03:35:36 UTC) #17
dnj (Google)
On 2016/02/12 03:35:36, iannucci wrote: > https://codereview.chromium.org/1679023005/diff/80001/common/clock/tags.go > File common/clock/tags.go (right): > > https://codereview.chromium.org/1679023005/diff/80001/common/clock/tags.go#newcode11 > ...
4 years, 10 months ago (2016-02-12 04:09:07 UTC) #18
iannucci
lgtm I think the Sleep behavior discrepancy is OK. The function signature is different than ...
4 years, 10 months ago (2016-02-12 04:17:36 UTC) #19
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1679023005/100001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1679023005/100001
4 years, 10 months ago (2016-02-13 00:42:34 UTC) #21
commit-bot: I haz the power
4 years, 10 months ago (2016-02-13 00:46:45 UTC) #23
Message was sent while issue was closed.
Committed patchset #6 (id:100001) as
https://github.com/luci/luci-go/commit/86e9094387fea7e47efe06fba090fe3118f66650

Powered by Google App Engine
This is Rietveld 408576698