workpool

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewWorker

func NewWorker(pool *workerPool) *worker

Types

type Pool

type Pool interface {
	// 提交任务
	Submit(task Task)        // 提交任务
	SubmitAndWait(task Task) // 提交任务并等待其执行
	Stopped() bool           // 如果协程停止,返回true
	Stop()                   // 停下来优雅地停止所有的勾当,所有挂起的任务将在退出前完成

}

开辟一个协程池:当有任务提交时,提交到协程池中运行;如果协程池都在工作,任务挂起

func NewDefaultPool

func NewDefaultPool(name string, maxWorkers int, idleTimeout time.Duration) Pool

func NewWorkerPool

func NewWorkerPool(name string, maxWorkers int, idleTimeout time.Duration) Pool

type Task

type Task func()

TODO Task 应该有输入和输出

Jump to

Keyboard shortcuts

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