Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Pool ¶
type Pool[A, R any] struct { // contains filtered or unexported fields }
Pool implements a simple goroutine pool.
func NewPool ¶
NewPool creates a new goroutine pool with the given number of workers and job queue capacity. If numWorkers is less than 1, it will be set to the number of CPUs. If cap (task queue capacity) is less than 1, it will be set to twice the number of workers.
func (*Pool[A, R]) AsyncMap ¶
func (p *Pool[A, R]) AsyncMap(handler func(A) R, args []A) []chan R
AsyncMap submits a batch of tasks and returns the channel to wait for the results.
func (*Pool[A, R]) AsyncSubmit ¶
func (p *Pool[A, R]) AsyncSubmit(handler func(A) R, args A) chan R
AsyncSubmit submits a task and returns the channel to wait for the result.
func (*Pool[A, R]) Close ¶
func (p *Pool[A, R]) Close()
Close closes the pool and waits for all the workers to stop.
Click to show internal directories.
Click to hide internal directories.