Documentation ¶
Index ¶
- Variables
- type FixedWorkerPool
- func (pool *FixedWorkerPool) QueueSize() int
- func (pool *FixedWorkerPool) Shutdown(ctx context.Context) error
- func (pool *FixedWorkerPool) SlotNum() int
- func (pool *FixedWorkerPool) Submit(group int, task func(*GoroutineLocal)) error
- func (pool *FixedWorkerPool) SubmitToAll(task func(*GoroutineLocal), blockingOnFull bool) error
- type GoroutineLocal
- type Pool
- type SimpleWorkerPool
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrWorkerPoolQueueIsFull = errors.New("queue of worker pool is full") ErrWorkerPoolClosed = errors.New("worker pool is closed") )
Functions ¶
This section is empty.
Types ¶
type FixedWorkerPool ¶
type FixedWorkerPool struct {
// contains filtered or unexported fields
}
FixedWorkerPool
@Description: 固定工作器池
func NewFixedIoWorkerPool ¶
func NewFixedIoWorkerPool(ioEventTimeRatio float64, ioEventQueueSize int, blockingOnFull bool) (*FixedWorkerPool, error)
func NewFixedWorkerPool ¶
func NewFixedWorkerPool(slotNum, queueSize int, blockingOnFull bool) (*FixedWorkerPool, error)
func (*FixedWorkerPool) QueueSize ¶
func (pool *FixedWorkerPool) QueueSize() int
func (*FixedWorkerPool) SlotNum ¶
func (pool *FixedWorkerPool) SlotNum() int
func (*FixedWorkerPool) Submit ¶
func (pool *FixedWorkerPool) Submit(group int, task func(*GoroutineLocal)) error
func (*FixedWorkerPool) SubmitToAll ¶
func (pool *FixedWorkerPool) SubmitToAll(task func(*GoroutineLocal), blockingOnFull bool) error
type GoroutineLocal ¶
type GoroutineLocal struct {
// contains filtered or unexported fields
}
GoroutineLocal
@Description: Goroutine 本地对象
func (*GoroutineLocal) Range ¶
func (local *GoroutineLocal) Range(op func(key, val any) bool)
func (*GoroutineLocal) Remove ¶
func (local *GoroutineLocal) Remove(key any)
func (*GoroutineLocal) Set ¶
func (local *GoroutineLocal) Set(key any, value any)
type Pool ¶
type Pool interface { // Submit // @Description: 提交任务到工作池 // @param group 任务分组 // @param task 任务 // @return error 提交失败时返回错误 // 如果工作队列已满,将返回 ErrWorkerPoolQueueIsFull 错误; // 如果工作池已经被关闭,则将返回 ErrWorkerPoolClosed 错误; // @throwable 提交任务时可能会抛出异常,在必要时自行捕捉 // Submit(group int, task func(*GoroutineLocal)) error // Shutdown // @Description: 关闭工作池 // @param ctx // @return error 关闭失败时返回错误 // 如果工作池已经关闭或在关闭中,将返回 ErrWorkerPoolClosed // Shutdown(ctx context.Context) error }
Pool
@Description: 执行工作池
type SimpleWorkerPool ¶
type SimpleWorkerPool struct {
// contains filtered or unexported fields
}
SimpleWorkerPool
@Description: 提交即执行的工作池
func NewSimpleWorkerPool ¶
func NewSimpleWorkerPool() *SimpleWorkerPool
func (*SimpleWorkerPool) Shutdown ¶
func (pool *SimpleWorkerPool) Shutdown(ctx context.Context) error
func (*SimpleWorkerPool) Submit ¶
func (pool *SimpleWorkerPool) Submit(category int, task func(*GoroutineLocal)) error
Click to show internal directories.
Click to hide internal directories.