multi_threader

package module
v0.0.0-...-6d8ade2 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2024 License: MulanPSL-2.0 Imports: 4 Imported by: 0

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 线程池

threaderNum 开启线程数量,范围1~可用的逻辑 CPU 数
inChan 输入通道
outChan 输出通道
arg 用户配置

func NewPool

func NewPool(threaderNum int, arg ...any) *Pool

NewPool 创建线程池

threaderNum 开启线程数量,范围1~可用的逻辑 CPU 数
arg 用户配置

func (*Pool) Run

func (p *Pool) Run(productFun func() []any, consumerFun func(int, any), handleFun func(any) any)

Run 运行

productFun 生产者函数 返回待处理数据集切片
consumerFun 消费者函数,入参为索引和处理者返回数据
handleFun 处理者函数,入参为生产者返回数据集中的每个元素

Jump to

Keyboard shortcuts

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