Documentation
¶
Overview ¶
Package kchanthreadpool 协程池 说明 使用channel做任务队列的协程池 每个协程仅从自身任务队列中取任务,这样可以减少锁的争抢 每个任务可分配至最少任务的队列中,也可根据任务key值分配到相同的任务池,以此来保证任务的严格串行
Index ¶
- type PoolHandlerIF
- type PoolStatus
- type Task
- type TaskJobIF
- type ThreadPool
- func (tp *ThreadPool) AddTaskByKey(elem *Task) (busy bool, retErr error)
- func (tp *ThreadPool) AddTaskByMini(elem *Task) (busy bool, retErr error)
- func (tp *ThreadPool) GetTaskInfo() string
- func (tp *ThreadPool) GetTaskSize() int
- func (tp *ThreadPool) Start() error
- func (tp *ThreadPool) Stop() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PoolHandlerIF ¶
PoolHandlerIF handler for upper apps
type PoolStatus ¶
type PoolStatus int
PoolStatus pool status
const ( // PoolStatusClosed closed PoolStatusClosed PoolStatus = 0 // PoolStatusInitialized initialized PoolStatusInitialized PoolStatus = 1 // PoolStatusStarting starting PoolStatusStarting PoolStatus = 2 // PoolStatusRunning running PoolStatusRunning PoolStatus = 3 // PoolStatusStopping stopping PoolStatusStopping PoolStatus = 4 )
type ThreadPool ¶
type ThreadPool struct {
// contains filtered or unexported fields
}
ThreadPool thread pool
func NewThreadPool ¶
func NewThreadPool(num uint, buffsize int, cb PoolHandlerIF) (*ThreadPool, error)
NewThreadPool new thread pool
func (*ThreadPool) AddTaskByKey ¶
func (tp *ThreadPool) AddTaskByKey(elem *Task) (busy bool, retErr error)
AddTaskByKey add task
@return busy bool : true -- buff is full, you may need to try again @return retErr error : error
func (*ThreadPool) AddTaskByMini ¶
func (tp *ThreadPool) AddTaskByMini(elem *Task) (busy bool, retErr error)
AddTaskByMini add task
@return busy bool : true -- buff is full, you may need to try again @return retErr error : error
Click to show internal directories.
Click to hide internal directories.