WithContext converts the pool to a ContextPool for tasks that should run under the same context, such that they each respect shared cancellation. For example, WithCancelOnError can be configured on the returned pool to signal that all goroutines should be cancelled upon the first error.
(ctx context.Context)
| 43 | // For example, WithCancelOnError can be configured on the returned pool to |
| 44 | // signal that all goroutines should be cancelled upon the first error. |
| 45 | func (p *ErrorPool) WithContext(ctx context.Context) *ContextPool { |
| 46 | p.panicIfInitialized() |
| 47 | ctx, cancel := context.WithCancel(ctx) |
| 48 | return &ContextPool{ |
| 49 | errorPool: p.deref(), |
| 50 | ctx: ctx, |
| 51 | cancel: cancel, |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | // WithFirstError configures the pool to only return the first error |
| 56 | // returned by a task. By default, Wait() will return a combined error. |
nothing calls this directly
no test coverage detected