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

Unified Diff: common/sync/parallel/workPool.go

Issue 2958433002: [errors] Remove Fix(), move MultiErrorFromErrors(). (Closed)
Patch Set: Created 3 years, 6 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
« no previous file with comments | « common/sync/parallel/multierror_test.go ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: common/sync/parallel/workPool.go
diff --git a/common/sync/parallel/workPool.go b/common/sync/parallel/workPool.go
index b1592b068271eff2168e0954e1d5c28f9d456281..b552c5c876a66619b4ad117f169fca9efdda39d6 100644
--- a/common/sync/parallel/workPool.go
+++ b/common/sync/parallel/workPool.go
@@ -17,7 +17,7 @@ import (
// WorkPool blocks until all the generator completes and all workers have
// finished their tasks.
func WorkPool(workers int, gen func(chan<- func() error)) error {
- return errors.MultiErrorFromErrors(Run(workers, gen))
+ return MultiErrorFromErrors(Run(workers, gen))
}
// FanOutIn is useful to quickly parallelize a group of tasks.
@@ -34,3 +34,23 @@ func WorkPool(workers int, gen func(chan<- func() error)) error {
func FanOutIn(gen func(chan<- func() error)) error {
return WorkPool(0, gen)
}
+
+// MultiErrorFromErrors takes an error-channel, blocks on it, and returns
+// a MultiError for any errors pushed to it over the channel, or nil if
+// all the errors were nil.
+func MultiErrorFromErrors(ch <-chan error) error {
Vadim Sh. 2017/06/23 00:32:16 does it have to be public? Anyone uses it besides
+ if ch == nil {
+ return nil
+ }
+ ret := errors.MultiError(nil)
+ for e := range ch {
+ if e == nil {
+ continue
+ }
+ ret = append(ret, e)
+ }
+ if len(ret) == 0 {
+ return nil
+ }
+ return ret
+}
« no previous file with comments | « common/sync/parallel/multierror_test.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698