Skip to content

Commit

Permalink
revert name change
Browse files Browse the repository at this point in the history
  • Loading branch information
camdencheek committed Dec 27, 2023
1 parent 0d8e4e3 commit e1e9af2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions pool/result_context_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
type ResultContextPool[T any] struct {
contextPool ContextPool
agg resultAggregator[T]
includeErrored bool
collectErrored bool
}

// Go submits a task to the pool. If all goroutines in the pool
Expand All @@ -32,15 +32,15 @@ func (p *ResultContextPool[T]) Go(f func(context.Context) (T, error)) {
// returns an error if any of the tasks errored.
func (p *ResultContextPool[T]) Wait() ([]T, error) {
err := p.contextPool.Wait()
return p.agg.collect(p.includeErrored), err
return p.agg.collect(p.collectErrored), err
}

// WithCollectErrored configures the pool to still collect the result of a task
// even if the task returned an error. By default, the result of tasks that errored
// are ignored and only the error is collected.
func (p *ResultContextPool[T]) WithCollectErrored() *ResultContextPool[T] {
p.panicIfInitialized()
p.includeErrored = true
p.collectErrored = true
return p
}

Expand Down
6 changes: 3 additions & 3 deletions pool/result_error_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
type ResultErrorPool[T any] struct {
errorPool ErrorPool
agg resultAggregator[T]
includeErrored bool
collectErrored bool
}

// Go submits a task to the pool. If all goroutines in the pool
Expand All @@ -34,15 +34,15 @@ func (p *ResultErrorPool[T]) Go(f func() (T, error)) {
// returning the results and any errors from tasks.
func (p *ResultErrorPool[T]) Wait() ([]T, error) {
err := p.errorPool.Wait()
return p.agg.collect(p.includeErrored), err
return p.agg.collect(p.collectErrored), err
}

// WithCollectErrored configures the pool to still collect the result of a task
// even if the task returned an error. By default, the result of tasks that errored
// are ignored and only the error is collected.
func (p *ResultErrorPool[T]) WithCollectErrored() *ResultErrorPool[T] {
p.panicIfInitialized()
p.includeErrored = true
p.collectErrored = true
return p
}

Expand Down
4 changes: 2 additions & 2 deletions pool/result_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,12 @@ func (r *resultAggregator[T]) save(i int, res T, errored bool) {
}

// collect returns the set of aggregated results.
func (r *resultAggregator[T]) collect(includeErrored bool) []T {
func (r *resultAggregator[T]) collect(collectErrored bool) []T {
if !r.mu.TryLock() {
panic("collect should not be called until all goroutines have exited")
}

if includeErrored || len(r.errored) == 0 {
if collectErrored || len(r.errored) == 0 {
return r.results
}

Expand Down

0 comments on commit e1e9af2

Please sign in to comment.