Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Pool ¶
type Pool[T any] struct { // contains filtered or unexported fields }
func NewPool ¶
NewPool creates a new goroutine pool. It is recommended to use the global funcs Go() in most cases. Creating your own pool for a specific func signature can eliminate the allocation of args. Idled goroutines will be removed automatically. The pace is depending on the runtime GC. After the GC finishing, all workers will be marked as idle. After the GC finishing again, workers that are still marked as idle will be removed. This logic is kind same as sync.Pool.
func (*Pool[T]) Close ¶
func (p *Pool[T]) Close()
Close the pool gc goroutine and all idled workers. It won't stop any busy worker. After the pool being closed, GoArgs() can still be called but it will fallback to "go".
Click to show internal directories.
Click to hide internal directories.