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

Unified Diff: common/gcloud/pubsub/subscriber/subscriber.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 side-by-side diff with in-line comments
Download patch
Index: common/gcloud/pubsub/subscriber/subscriber.go
diff --git a/common/gcloud/pubsub/subscriber/subscriber.go b/common/gcloud/pubsub/subscriber/subscriber.go
index 53300d8594ceb362a786edaf8bfdb0e3869dcb76..bdefe9d11238e5287ca5eb74da5787187b765f70 100644
--- a/common/gcloud/pubsub/subscriber/subscriber.go
+++ b/common/gcloud/pubsub/subscriber/subscriber.go
@@ -164,18 +164,5 @@ func (s *Subscriber) noDataSleep(c context.Context) {
if d <= 0 {
d = DefaultNoDataDelay
}
- cancellableSleep(c, d)
-}
-
-// cancellableSleep sleeps, returning either when the sleep duration has expired
-// or the supplied context has been canceled.
-func cancellableSleep(c context.Context, delay time.Duration) {
- // Sleep for "delay", stopping early if our Context is canceled.
- select {
- case <-clock.After(c, delay):
- break
-
- case <-c.Done():
- break
- }
+ clock.Sleep(c, d)
}

Powered by Google App Engine
This is Rietveld 408576698