package
Version:
v0.28.1
Opens a new window with list of versions in this module.
Published: Dec 11, 2021
License: MIT
Opens a new window with license information.
Imports: 2
Opens a new window with list of imports.
Imported by: 4
Opens a new window with list of known importers.
Documentation
¶
非阻塞协程池,协程数量可动态增长,可配置最大协程并发数量,可手动释放空闲的协程
func Go(task TaskFn, param ...interface{})
func NewWorker(p *pool) *worker
type ModOption func(option *Option)
type Option struct {
InitWorkerNum int
MaxWorkerNum int
}
type Pool interface {
Go(task TaskFn, param ...interface{})
GetCurrentStatus() Status
KillIdleWorkers()
}
并发计算0+1+2+...+1000
演示怎么向协程池中添加带参数的函数任务
Output:
499500
type Status struct {
TotalWorkerNum int
IdleWorkerNum int
BlockTaskNum int
}
func GetCurrentStatus() Status
type TaskFn func(param ...interface{})
Source Files
¶
Click to show internal directories.
Click to hide internal directories.