pool

package
v0.0.0-...-d588655 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultCapacity = 50               // 容量,最大的协程数量
	DefaultTimeOut  = 30 * time.Second // 任务执行的时间,超过该时间协程会退出执行该程序,返回空闲状态
	DefaultIdleTime = 10 * time.Minute // 协程空闲的时间,超过该时间会自动
)

Variables

This section is empty.

Functions

This section is empty.

Types

type GoroutinePool

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

func NewGoroutinePool

func NewGoroutinePool(opts ...Option) *GoroutinePool

func (*GoroutinePool) Close

func (p *GoroutinePool) Close()

func (*GoroutinePool) Submit

func (p *GoroutinePool) Submit(task f) error

Submit 提交执行的任务

type Option

type Option func(pool *GoroutinePool)

func WithCapacity

func WithCapacity(capacity int32) Option

func WithIdleTime

func WithIdleTime(idleTime time.Duration) Option

func WithTimeout

func WithTimeout(timeout time.Duration) Option

type Worker

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

Worker 对协程进行封装的worker,每一个worker绑定一个goroutine

func (*Worker) Close

func (w *Worker) Close()

Jump to

Keyboard shortcuts

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