func WithPreAllocWorkers(size int) PoolOption {
	if size < 0 {
		panic(errors.New("the pre-allocated number of workers must be greater than or equal to zero"))
	}
	return func(opts *poolOption) {
		opts.preAllocWorkers = size
	}
}
WithPreAllocWorkers sets up the number of workers to spawn when initializing Pool.
package goroutines
import (
	"errors"
	"time"
)
const (
	defaultPreAllocWorkers = -1
	defaultAdjustPeriod    = 0
	defaultBatchSize = 10
)
type PoolOption func(opts *poolOption)
type poolOption struct {
	taskQueueLength int
	preAllocWorkers int
	workerAdjustPeriod time.Duration
}
func loadPoolOption(options ...PoolOption) *poolOption {
	opts := &poolOption{
		preAllocWorkers:    defaultPreAllocWorkers,
		workerAdjustPeriod: defaultAdjustPeriod,
	}
	for _, option := range options {
		option(opts)
	}
	return opts
}
func WithTaskQueueLength(length int) PoolOption {
	if length < 0 {
		panic(errors.New("the length of task queue must be greater than or equal to zero"))
	}
	return func(opts *poolOption) {
		opts.taskQueueLength = length
	}
}