Documentation ¶
Index ¶
- Constants
- func OnOffsetTimeNewDayEvent(name string)
- func OnSystemNewDayEvent(name string)
- func RegOffsetTimeNewDayEvent(ticker *Ticker, name string, offset *offset.Time, trigger bool, ...)
- func RegSystemNewDayEvent(ticker *Ticker, name string, trigger bool, handle SystemNewDayEventHandle)
- func SetPoolSize(size int)
- type OffsetTimeNewDayEventHandle
- type Option
- type Pool
- type Scheduler
- type SystemNewDayEventHandle
- type Ticker
- func (slf *Ticker) After(name string, after time.Duration, handleFunc interface{}, args ...interface{})
- func (slf *Ticker) Cron(name, expression string, handleFunc interface{}, args ...interface{})
- func (slf *Ticker) CronByInstantly(name, expression string, handleFunc interface{}, args ...interface{})
- func (slf *Ticker) GetSchedulers() []string
- func (slf *Ticker) IsStopped(name string) bool
- func (slf *Ticker) Loop(name string, after, interval time.Duration, times int, handleFunc interface{}, ...)
- func (slf *Ticker) Mark() string
- func (slf *Ticker) Release()
- func (slf *Ticker) StopTimer(name string)
Constants ¶
View Source
const ( Forever = -1 // 无限循环 Once = 1 // 一次 Instantly = 0 // 立刻 )
View Source
const (
DefaultTickerPoolSize = 96
)
View Source
const (
NoMark = "" // 没有设置标记的定时器
)
Variables ¶
This section is empty.
Functions ¶
func OnOffsetTimeNewDayEvent ¶ added in v0.0.28
func OnOffsetTimeNewDayEvent(name string)
OnOffsetTimeNewDayEvent 偏移时间新的一天事件
func OnSystemNewDayEvent ¶ added in v0.0.28
func OnSystemNewDayEvent(name string)
OnSystemNewDayEvent 系统新的一天事件
func RegOffsetTimeNewDayEvent ¶ added in v0.0.28
func RegOffsetTimeNewDayEvent(ticker *Ticker, name string, offset *offset.Time, trigger bool, handle OffsetTimeNewDayEventHandle)
RegOffsetTimeNewDayEvent 注册偏移时间新的一天事件
- 建议全局注册一个事件后再另行拓展
- 与 RegSystemNewDayEvent 类似,但是触发时间为 offset 时间到达每天的 00:00:00
func RegSystemNewDayEvent ¶ added in v0.0.28
func RegSystemNewDayEvent(ticker *Ticker, name string, trigger bool, handle SystemNewDayEventHandle)
RegSystemNewDayEvent 注册系统新的一天事件
- 建议全局注册一个事件后再另行拓展
- 将特定 name 的定时任务注册到 ticker 中,在系统时间到达每天的 00:00:00 时触发,如果 trigger 为 true,则立即触发一次
func SetPoolSize ¶ added in v0.3.6
func SetPoolSize(size int)
SetPoolSize 设置标准池定时器池大小
- 默认值为 DefaultTickerPoolSize,当定时器池中的定时器不足时,会自动创建新的定时器,当定时器释放时,会将多余的定时器进行释放,否则将放入定时器池中
Types ¶
type OffsetTimeNewDayEventHandle ¶ added in v0.0.28
type OffsetTimeNewDayEventHandle func()
type Pool ¶ added in v0.3.6
type Pool struct {
// contains filtered or unexported fields
}
Pool 定时器池
func NewPool ¶ added in v0.3.6
NewPool 创建一个定时器池,当 tickerPoolSize 小于等于 0 时,将会引发 panic,可指定为 DefaultTickerPoolSize
func (*Pool) ChangePoolSize ¶ added in v0.3.6
ChangePoolSize 改变定时器池大小
- 当传入的大小小于或等于 0 时,将会返回错误,并且不会发生任何改变
type SystemNewDayEventHandle ¶ added in v0.0.28
type SystemNewDayEventHandle func()
type Ticker ¶
type Ticker struct {
// contains filtered or unexported fields
}
Ticker 定时器
func (*Ticker) After ¶
func (slf *Ticker) After(name string, after time.Duration, handleFunc interface{}, args ...interface{})
After 设置一个在特定时间后运行一次的调度器
func (*Ticker) CronByInstantly ¶ added in v0.3.6
func (slf *Ticker) CronByInstantly(name, expression string, handleFunc interface{}, args ...interface{})
CronByInstantly 与 Cron 相同,但是会立即执行一次
Click to show internal directories.
Click to hide internal directories.