poolKit

package
v2.8.153 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 20, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NewPool func(size int, options ...ants.Option) (*ants.Pool, error) = ants.NewPool

NewPool 创建 *ants.Pool 实例.

PS: (1) 通过 Pool.Submit() 执行任务,任务无参无返回值. (2) 默认情况下(即不传options):

(a) (Nonblocking: false) 阻塞模式
(b) (MaxBlockingTasks: 0) 阻塞模式下,最多因为调用Pool.Submit()而阻塞的goroutine数量 不设限制.

(3) 可以通过 ants.WithLogger() 指定日志输出(默认输出到控制台); (4) 可以通过 ants.WithPanicHandler() 处理goroutine发生的panic,否则通过Logger输出.

@param size (1) 如果<=0,生成的池是无限制的;

(2) 即cap;
(3) 并不是传了多少就立即创建多少协程.
View Source
var NewPoolWithFunc func(size int, pf func(interface{}), options ...ants.Option) (*ants.PoolWithFunc, error) = ants.NewPoolWithFunc

NewPoolWithFunc 创建 *ants.PoolWithFunc 实例.

PS: (1) 通过 Pool.Submit() 执行任务,任务无参无返回值. (2) 默认情况下(即不传options):

(a) (Nonblocking: false) 阻塞模式
(b) (MaxBlockingTasks: 0) 阻塞模式下,最多因为调用Pool.Submit()而阻塞的goroutine数量 不设限制.

(3) 可以通过 ants.WithLogger() 指定日志输出(默认输出到控制台); (4) 可以通过 ants.WithPanicHandler() 处理goroutine发生的panic,否则通过Logger输出.

@param size (1) 如果<=0,生成的池是无限制的;

(2) 即cap;
(3) 并不是传了多少就立即创建多少协程.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL