This commit is contained in:
Kevin Wan
2021-08-26 16:47:28 +08:00
committed by GitHub
parent aa68210cde
commit d0f9e57022
2 changed files with 22 additions and 0 deletions

View File

@@ -112,6 +112,12 @@ func MapReduceWithSource(source <-chan interface{}, mapper MapperFunc, reducer R
opts ...Option) (interface{}, error) {
options := buildOptions(opts...)
output := make(chan interface{})
defer func() {
for range output {
panic("more than one element written in reducer")
}
}()
collector := make(chan interface{}, options.workers)
done := syncx.NewDoneChan()
writer := newGuardedWriter(output, done.Done())