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() { |
+ for i := 0; i < cap(s); i++ { |
+ s.Lock() |
+ } |
+} |