task

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: Apache-2.0 Imports: 1 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pool

type Pool struct {
	// contains filtered or unexported fields
}

Pool 极简工作池 - 使用 Go 原生原语实现并发控制 替代 ants 框架,仅保留核心功能:限制最大并发数 + 等待所有任务完成

func NewPool

func NewPool(maxWorkers int) *Pool

NewPool 创建工作池,maxWorkers 为最大并发数

func (*Pool) Add

func (p *Pool) Add(delta int)

Add 手动增加计数(兼容原有逻辑)

func (*Pool) Done

func (p *Pool) Done()

Done 手动完成计数(兼容原有逻辑)

func (*Pool) Go

func (p *Pool) Go(task func())

Go 提交一个无参数任务

func (*Pool) GoWith

func (p *Pool) GoWith(arg any, task func(any))

GoWith 提交一个带参数的任务,替代 ants.PoolWithFunc.Invoke

func (*Pool) Wait

func (p *Pool) Wait()

Wait 等待所有任务完成

Jump to

Keyboard shortcuts

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