752fb2e2c0
Text Extraction Clean Up + Parallelization * merged_Call * directchildren * bitofimprovements * go * parallel * fixfullsuite * pondforconcurrency * comments * muchdone * bitsofclean * stabilisedtests * snappy * threadpooltests * childelements * testspassed
30 lines
613 B
Go
30 lines
613 B
Go
package pond
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
type Option func(*pool)
|
|
|
|
// WithContext sets the context for the pool.
|
|
func WithContext(ctx context.Context) Option {
|
|
return func(p *pool) {
|
|
p.ctx = ctx
|
|
}
|
|
}
|
|
|
|
// WithQueueSize sets the max number of elements that can be queued in the pool.
|
|
func WithQueueSize(size int) Option {
|
|
return func(p *pool) {
|
|
p.queueSize = size
|
|
}
|
|
}
|
|
|
|
// WithNonBlocking sets the pool to be non-blocking when the queue is full.
|
|
// This option is only effective when the queue size is set.
|
|
func WithNonBlocking(nonBlocking bool) Option {
|
|
return func(p *pool) {
|
|
p.nonBlocking = nonBlocking
|
|
}
|
|
}
|