Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ITimer ¶
type ITimer interface {
Start(ctx context.Context) error
Stop()
ITimerSecond
ITimerMillisecond
}
var GTimer ITimer
type ITimerMillisecond ¶
type ITimerMillisecond interface {
AddMillisecond(callBackFunc xcontrol.ICallBack, expireMillisecond int64, out xcontrol.IOut) *Millisecond // callBackFunc: 到期-回调函数 expireMillisecond: 到期 时间戳(毫秒) out: 到期-输出
DelMillisecond(millisecond *Millisecond)
}
type ITimerSecond ¶
type Millisecond ¶
type Millisecond struct {
xcontrol.ISwitchButton // 有效(false:不执行,扫描时自动删除)
xcontrol.ICallBack // 到期-回调函数
xcontrol.IOut // 到期-输出
// contains filtered or unexported fields
}
Millisecond 毫秒级定时器
func (*Millisecond) GetExpire ¶
func (p *Millisecond) GetExpire() int64
type MillisecondMinHeap ¶
type MillisecondMinHeap []*MillisecondTask
MillisecondMinHeap 毫秒-数据-小顶堆
⚠️只允许通过 heap 包操作,不要直接用 append/sort...
func (*MillisecondMinHeap) Len ¶
func (p *MillisecondMinHeap) Len() int
func (*MillisecondMinHeap) Less ¶
func (p *MillisecondMinHeap) Less(i, j int) bool
func (*MillisecondMinHeap) Pop ¶
func (p *MillisecondMinHeap) Pop() any
func (*MillisecondMinHeap) Push ¶
func (p *MillisecondMinHeap) Push(x any)
func (*MillisecondMinHeap) Swap ¶
func (p *MillisecondMinHeap) Swap(i, j int)
type MillisecondTask ¶
type MillisecondTask struct {
// contains filtered or unexported fields
}
MillisecondTask 表示一个毫秒级定时任务
seq 用于保证相同到期时间时先来先出
func NewMilliTask ¶
func NewMilliTask(expire int64, millisecond *Millisecond) *MillisecondTask
NewMilliTask 创建新任务,自动分配序号
Source Files
¶
Click to show internal directories.
Click to hide internal directories.