pool

package
v1.8.20 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultPoolSize    = 1               // 线程池默认线程数
	DefaultIdleTimeout = time.Second * 5 // 如果5秒线程未被重复使用,则立即回收线程
)

pool default config params

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	Size        int           // 线程池容量大小
	IdleTimeout time.Duration // 线程池线程idle时间,超过idle时间
}

Options default option struct

type Pool

type Pool struct {
	sync.Mutex
	Size int32 // 最大worker发数据

	IdleTimeout time.Duration // 线程闲置时间
	// contains filtered or unexported fields
}

Pool pool struct

func NewPool

func NewPool(options *Options) *Pool

NewPool create

func (*Pool) Close

func (p *Pool) Close()

Close the pool

func (*Pool) Submit

func (p *Pool) Submit(callbackFunc func())

Submit one task to pool

type Task

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

Task pool single task

Jump to

Keyboard shortcuts

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