Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ITimingTask ¶
type ITimingTask interface { RunAt() int64 Run(schedule *TimingSchedule) OnError(err error) }
调度器接收的任务接口
type ThreadPool ¶
type ThreadPool struct {
// contains filtered or unexported fields
}
定义协程池
func NewThreadPool ¶
func NewThreadPool(maxGoroutines int, initSize, maxSize int) *ThreadPool
NewThreadPool 创建协程池,maxGoroutines指定工作协程数量,initSize指定任务队列初始大小, maxSize指定任务队列上限,达到上限后,Push会等待;maxSize为0表示无上限,即Push操作不会等待
type TimingSchedule ¶
type TimingSchedule struct {
// contains filtered or unexported fields
}
func NewTimingSchedule ¶
func NewTimingSchedule(workerCount int, intervalS int, tasks ...ITimingTask) *TimingSchedule
func (*TimingSchedule) IsShutdown ¶
func (s *TimingSchedule) IsShutdown() bool
IsShutdown 判断调度器是否处于关闭状态
func (*TimingSchedule) Push ¶
func (s *TimingSchedule) Push(t ITimingTask)
Push 向调度器中添加任务,如果调度器处于关闭状态,Push无效
Click to show internal directories.
Click to hide internal directories.