Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrInvaildWorkerCapacity = errors.New("nyn: worker capacity must > 0")
ErrInvaildWorkerCapacity 是设置了不正确的 worker 容量时返回的错误
Functions ¶
This section is empty.
Types ¶
type WorkerPool ¶
type WorkerPool struct {
// contains filtered or unexported fields
}
WorkerPool 是 worker pool
func NewWorkerPool ¶
func NewWorkerPool(workerCount int) (pool *WorkerPool)
NewWorkerPool 返回一个新的 WorkerPool
func (*WorkerPool) AddWorkIfCouldSync ¶
func (pool *WorkerPool) AddWorkIfCouldSync(workProvider func() (work func())) bool
AddWorkIfCouldSync 在还能添加工作时, 添加 workProvider 所返回的工作. 返回能否添加工作 如果 workProvider 返回了 nil, 会视为 hang
func (*WorkerPool) SetCapacity ¶
func (pool *WorkerPool) SetCapacity(i int) (err error)
SetCapacity 设置 worker pool 的 worker 容量
func (*WorkerPool) SetLogger ¶
func (pool *WorkerPool) SetLogger(logger logger.Logger)
SetLogger 设置 logger
Click to show internal directories.
Click to hide internal directories.