heap_timer

package
v1.3.15 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2023 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TriggerModeMore = 0
	TriggerModeOnce = 1
)

Variables

This section is empty.

Functions

func NewTimer

func NewTimer(ctx any, hand TimerHandler, dur time.Duration, repeat int) *timer

func NewTimerWithFirstDo

func NewTimerWithFirstDo(ctx any, hand TimerHandler, firstFireAt time.Time, dur time.Duration, repeat int) *timer

func ResetNowTime

func ResetNowTime(nowTime time.Time)

Types

type Timer

type Timer interface {
	Reset(ctx any, dur time.Duration, repeat ...int) bool
	Kill()       //kill以后,对象不能在使用,应用层不可继续操作
	Pause() bool //暂停后可继续持有对象Reset
	Context() any
}

type TimerChannel

type TimerChannel struct {
	C chan TimerMsg
}

func (*TimerChannel) OnTime

func (t *TimerChannel) OnTime(msg TimerMsg)

type TimerHandler

type TimerHandler interface {
	OnTime(msg TimerMsg)
}

type TimerMsg

type TimerMsg struct {
	Timer   Timer // 定时器上下文
	Times   int   // 定时器触发次数
	NowTime time.Time
}

type TimerTriggerMode

type TimerTriggerMode = int

Jump to

Keyboard shortcuts

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