Documentation
¶
Index ¶
- type Options
- type Task
- type WorkerPool
- func (wp *WorkerPool) Close()
- func (wp *WorkerPool) GetMu() *sync.Mutex
- func (wp *WorkerPool) GetWaitGroup() *sync.WaitGroup
- func (wp *WorkerPool) Resize(newSize int)
- func (wp *WorkerPool) RunningWorkers() int
- func (wp *WorkerPool) Submit(task func()) error
- func (wp *WorkerPool) SubmitAsync(task func()) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct {
Size int // 协程池容量
Expiry time.Duration // 空闲协程存活时间
PanicHandler func(interface{}) // Panic处理函数
}
Options 协程池配置选项
type Task ¶
type Task func() // 定义任务类型
type WorkerPool ¶
type WorkerPool struct {
// contains filtered or unexported fields
}
func (*WorkerPool) GetWaitGroup ¶
func (wp *WorkerPool) GetWaitGroup() *sync.WaitGroup
GetWaitGroup 获取 *sync.WaitGroup
func (*WorkerPool) Resize ¶
func (wp *WorkerPool) Resize(newSize int)
func (*WorkerPool) RunningWorkers ¶
func (wp *WorkerPool) RunningWorkers() int
RunningWorkers 获取当前运行中的worker数量
func (*WorkerPool) SubmitAsync ¶
func (wp *WorkerPool) SubmitAsync(task func()) error
SubmitAsync 异步提交任务(不等待执行)
Source Files
¶
- ants_pool.go
Click to show internal directories.
Click to hide internal directories.