schedule

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 21, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTodayTime

func NewTodayTime(value string) (int64, error)

NewTodayTime 通过value指定当天的具体时间,格式为 "hh:mm:ss"

e.g
NewToday("10:30:00")

Types

type ITheadTask

type ITheadTask interface {
	Do()
	OnPanic(err error)
	Priority() int64
}

定义协程任务接口

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操作不会等待

func (*ThreadPool) Exit

func (p *ThreadPool) Exit()

Exit 退出协程池

func (*ThreadPool) Push

func (p *ThreadPool) Push(t ITheadTask)

Push 向协程池任务队列中添加任务

func (*ThreadPool) Start

func (p *ThreadPool) Start()

Start 启动协程池

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) Len

func (s *TimingSchedule) Len() int

Len 查看调度器中的任务数量

func (*TimingSchedule) Push

func (s *TimingSchedule) Push(t ITimingTask)

Push 向调度器中添加任务,如果调度器处于关闭状态,Push无效

func (*TimingSchedule) Shutdown

func (s *TimingSchedule) Shutdown()

Shutdown 停止调度器

func (*TimingSchedule) Start

func (s *TimingSchedule) Start()

Start 启动调度器

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL