pool

package
v0.0.0-...-214a605 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2019 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterWorkerPool

func RegisterWorkerPool(name string, creator workerPoolCreator)

RegisterWorkerPool 注册一个pool. 如果name已存在,则panic

func WithIdentify

func WithIdentify(i Identifier) func(*Option)

Types

type Identifier

type Identifier interface {
	ID() uint64
}

type Option

type Option struct {
	Identifier Identifier
}

type Pool

type Pool interface {
	Run()
	// Stop停止pool,调用方阻塞直到Stop返回
	// pool保证此时剩余的pool item全部执行完毕才返回
	Stop()

	// Put往pool中投放任务,无论pool是否已满,此次投放必定成功
	Put(f func(), opts ...func(*Option))
	// TryPut与Put相同,但当pool已满试,投放失败,返回false
	TryPut(f func(), opts ...func(*Option)) bool

	String() string
}

Pool 是一个goroutine pool, 单独使用可用于限制并发数量, 作为gnet组件时还可以指定并发模型

func MustGetWorkerPool

func MustGetWorkerPool(name string) Pool

MustGetPacker 获取指定名字对应的pool. 若未注册,则panic

Directories

Path Synopsis
plugins

Jump to

Keyboard shortcuts

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