pool

package
v0.0.30 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2025 License: MIT Imports: 2 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 封装的 worker pool

func New

func New(size int) (*Pool, error)

New 创建一个新的 worker pool size: 池子大小

func (*Pool) Release

func (wp *Pool) Release()

Release 释放资源

func (*Pool) Results

func (wp *Pool) Results() <-chan Result

Results 获取结果通道

func (*Pool) Submit

func (wp *Pool) Submit(task TaskFunc) error

Submit 提交一个任务

func (*Pool) Wait

func (wp *Pool) Wait()

Wait 等待所有任务完成

type Result

type Result struct {
	Value any
	Err   error
}

Result 表示任务执行结果

type TaskFunc

type TaskFunc func() (any, error)

TaskFunc 定义任务函数

Jump to

Keyboard shortcuts

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