Documentation ¶
Index ¶
- Constants
- type Config
- type ConfigIllegalError
- type GoroutinePoolConfigModifyingError
- type GoroutinePoolNotInitError
- type GoroutinePoolStoppedError
- type Pool
- func (p *Pool) AddTask(task func(), data interface{}, withBlock bool) (success bool, err error)
- func (p *Pool) ChangeKeepaliveTime(newKeepaliveTime time.Duration) (time.Duration, error)
- func (p *Pool) ChangeTaskWorkerCount(newMaxCount uint32) error
- func (p *Pool) GetStatus() (TaskWorkerStatus, error)
- func (p *Pool) Stop() error
- type TaskInfo
- type TaskWorkerStatus
Constants ¶
View Source
const ( MinTaskWorkerCount = 0 MaxTaskWorkerCount = (1 << (maxCountHighBit - maxCountLowBit + 1)) - 1 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // 初始TaskWorker的个数 InitialTaskWorkerCount uint32 // 并发运行的TaskWorker个数的最大值 MaxTaskWorkerCount uint32 // 每个TaskWorker的最大连续空闲时间长, 连续空闲时长超过此值的TaskWorker会结束退出 KeepaliveTime time.Duration // 处理Task执行过程中未捕获的panic, 为nil时不会进行调用 HandleTaskPanic func(err interface{}) // GoroutinePool状态周期巡查的时间间隔, 为0时标识关闭Goroutine状态周期巡查 MonitorTimeInterval time.Duration // 每轮GoroutinePool状态周期巡查完成后将调用MonitorCallback, 如果MonitorCallback返回true将启动Monitor Tasker // Monitor Tasker的作用是循环从taskChan获取TaskElem执行, 直到收到结束Monitor Tasker的信号后退出 MonitorCallback func(map[uint64]TaskInfo) bool }
type ConfigIllegalError ¶
type ConfigIllegalError struct {
// contains filtered or unexported fields
}
func (ConfigIllegalError) Error ¶
func (err ConfigIllegalError) Error() string
type GoroutinePoolConfigModifyingError ¶
type GoroutinePoolConfigModifyingError struct{}
func (GoroutinePoolConfigModifyingError) Error ¶
func (GoroutinePoolConfigModifyingError) Error() string
type GoroutinePoolNotInitError ¶
type GoroutinePoolNotInitError struct{}
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< error定义 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
func (GoroutinePoolNotInitError) Error ¶
func (GoroutinePoolNotInitError) Error() string
type GoroutinePoolStoppedError ¶
type GoroutinePoolStoppedError struct{}
func (GoroutinePoolStoppedError) Error ¶
func (GoroutinePoolStoppedError) Error() string
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool支持:
1:动态调整执行任务的Goroutine的个数(TaskWorkerCount) 2:动态调节Goroutine空闲超时自动退出的时间(KeepaliveTime) 3:Goroutine状态周期巡查(可用于监控任务执行时间, 发现和破除协程池死锁)
func NewDefaultPool ¶
func (*Pool) AddTask ¶
withBlock为true表示阻塞的将task放入p中执行, 为false表示非阻塞的放入, 非阻塞时如果p不存在空闲的TaskWorker, task将放入失败
func (*Pool) ChangeKeepaliveTime ¶
修改p的KeepaliveTime为newKeepaliveTime, 修改成功时返回(oldKeepaliveTime, nil)
func (*Pool) ChangeTaskWorkerCount ¶
修改p允许并发执行的TaskWorker的最大个数为newMaxCount
Click to show internal directories.
Click to hide internal directories.