Chromium Code Reviews| Index: common/parallel/workPool.go |
| diff --git a/common/parallel/workPool.go b/common/parallel/workPool.go |
| index 0e749eb07e108445b0cc357afbdeea328536673b..e27f5b828d7bf8e3ee6bee35540b4e08b74b953d 100644 |
| --- a/common/parallel/workPool.go |
| +++ b/common/parallel/workPool.go |
| @@ -23,8 +23,17 @@ func WorkPool(workers int, gen func(chan<- func() error)) error { |
| } |
| sem := make(Semaphore, workers) |
| - errchan := make(chan error, workers) |
| - funchan := make(chan func() error, workers) |
| + return Run(sem, gen) |
| +} |
| + |
| +// Run executes task functions produced by a generator method. Execution is |
| +// throttled by an optional Semaphore, requiring a token prior to dispatch. |
| +// |
| +// Run blocks until all the generator completes and all workers have finished |
| +// their tasks, returning a MultiError if a failure was encountered. |
| +func Run(sem Semaphore, gen func(chan<- func() error)) error { |
|
dnj (Google)
2016/01/21 04:36:24
Useful b/c the FanOutIn model is great, but someti
|
| + errchan := make(chan error, cap(sem)) |
| + funchan := make(chan func() error, cap(sem)) |
| go func() { |
| defer close(funchan) |