Chromium Code Reviews| 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() |
| + } |
| +} |