Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package parallel | 5 package parallel |
| 6 | 6 |
| 7 // FanOutIn is useful to quickly parallelize a group of tasks. | 7 // FanOutIn is useful to quickly parallelize a group of tasks. |
| 8 // | 8 // |
| 9 // You pass it a function which is expected to push simple `func() error` | 9 // You pass it a function which is expected to push simple `func() error` |
| 10 // closures into the provided chan. Each function will be executed in parallel | 10 // closures into the provided chan. Each function will be executed in parallel |
| 11 // and their error results will be collated. | 11 // and their error results will be collated. |
| 12 // | 12 // |
| 13 // The function blocks until all functions are executed, and an | 13 // The function blocks until all functions are executed, and an |
| 14 // errors.MultiError is returned if one or more of your fan-out tasks failed, | 14 // errors.MultiError is returned if one or more of your fan-out tasks failed, |
| 15 // otherwise this function returns nil. | 15 // otherwise this function returns nil. |
| 16 // | 16 // |
| 17 // This function is equivalent to WorkPool(0, gen). | 17 // This function is equivalent to WorkPool(0, gen). |
| 18 func FanOutIn(gen func(chan<- func() error)) error { | 18 func FanOutIn(gen func(chan<- func() error)) error { |
| 19 » return WorkPool(0, gen) | 19 » return Run(nil, gen) |
|
dnj (Google)
2016/01/21 04:36:24
Run is one WorkPool, but more baremetal.
| |
| 20 } | 20 } |
| OLD | NEW |