Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TaskPool ¶
type TaskPool struct {
// contains filtered or unexported fields
}
TaskPool 任务池
func NewTaskPool ¶
func NewTaskPool(poolName string, capacity int, opts ...TaskPoolOption) *TaskPool
NewTaskPool 通过此方法内部创建 ctx, 需要通过 Close() 来关闭协程池, 防止协程泄露
func (*TaskPool) Close ¶
func (t *TaskPool) Close()
Close 关闭协程池,
注意:
- 每次调用完一定要释放
- 局部使用推荐使用 SafeClose, 防止任务未执行完就退出
func (*TaskPool) FreeWorkerQueueLen ¶
FreeWorkerQueueLen 空闲队列池里的长度
type TaskPoolOption ¶
type TaskPoolOption func(p *TaskPool)
func WithCtx ¶ added in v1.2.10
func WithCtx(ctx context.Context) TaskPoolOption
WithCtx 外部设置 content.Context
func WithPolTime ¶
func WithPolTime(t time.Duration) TaskPoolOption
WithPolTime 设置 taskPool 中哨兵轮询地时间
func WithPoolPrint ¶ added in v1.2.6
func WithPoolPrint(print bool) TaskPoolOption
WithPoolPrint 设置是否打印 log
func WithWorkerMaxLifeCycle ¶
func WithWorkerMaxLifeCycle(timeForSec sec) TaskPoolOption
WithWorkerMaxLifeCycle 设置 taskPool 中空闲的 worker 存活的时间
Click to show internal directories.
Click to hide internal directories.