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

Unified Diff: common/parallel/semaphore.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
« common/meter/meter.go ('K') | « common/meter/meter_test.go ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: common/parallel/semaphore.go
diff --git a/common/parallel/semaphore.go b/common/parallel/semaphore.go
index c2ddafb80a5839745b1ceb6eadb88fed07f36f84..f8299a59b0f0f721e2d22219d4ce6b3011df83df 100644
--- a/common/parallel/semaphore.go
+++ b/common/parallel/semaphore.go
@@ -25,3 +25,11 @@ func (s Semaphore) Unlock() {
<-s
}
}
+
+// TakeAll blocks until it holds all available semaphore resources. When it
+// returns, the caller owns all of the resources in the semaphore.
+func (s Semaphore) TakeAll() {
dnj (Google) 2016/02/10 03:19:04 This is really useful. Before, one would have to u
+ for i := 0; i < cap(s); i++ {
+ s.Lock()
+ }
+}
« common/meter/meter.go ('K') | « common/meter/meter_test.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698