MCPcopy Index your code
hub / github.com/sourcegraph/conc / WithContext

Method WithContext

pool/error_pool.go:45–53  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

43// For example, WithCancelOnError can be configured on the returned pool to
44// signal that all goroutines should be cancelled upon the first error.
45func (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.

Callers

nothing calls this directly

Calls 2

panicIfInitializedMethod · 0.95
derefMethod · 0.95

Tested by

no test coverage detected