workerGeneric

package
v2.3.1 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Job

type Job[T any] struct {
	// 工作函数,接受泛型参数
	Func func(T)
	// 工作参数,类型为泛型 T
	Params T
}

Job 结构体现在支持泛型

type StartWorker

type StartWorker[T any] struct {
	// 最大运行数
	MaxSize    int `ini:"max_size"`
	WorkerPool chan chan Job[T]
	// contains filtered or unexported fields
}

StartWorker 定义开始工作结构体,支持泛型

func (*StartWorker[T]) Close

func (s *StartWorker[T]) Close() error

Close 关闭所有worker

func (*StartWorker[T]) Init

func (s *StartWorker[T]) Init()

Init 初始化工作池

func (*StartWorker[T]) Run

func (s *StartWorker[T]) Run(j *Job[T])

Run 运行,支持泛型

Jump to

Keyboard shortcuts

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