timerwheel

package
v0.0.0-...-0012533 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//最小一组数据的个数
	ArrayListMax = 1000
)

Variables

View Source
var (
	PoolListE  *sync.Pool
	PoolBucket *sync.Pool
)

Functions

func TimerSetAccuracy

func TimerSetAccuracy(n int64) option

设置最小刻度(毫秒)

func TimerSetNow

func TimerSetNow(n time.Time) option

设置开始时间

Types

type ITimer

type ITimer interface {
	//一次任务 返回值(定时任务ID)
	OnceTimer(delayTime time.Duration, callback func(...interface{}), params ...interface{}) uint64
	//循环任务 返回值(定时任务ID)
	LoopTimer(intervalTime time.Duration, callback func(...interface{}), params ...interface{}) uint64

	//循环次数任务 返回值(定时任务ID)
	LoopTimerByCount(intervalTime time.Duration, loopCount int, callback func(...interface{}), params ...interface{}) uint64

	//循环延时任务 返回值(定时任务ID)
	LoopDelayTimer(delayTime time.Duration, intervalTime time.Duration, callback func(...interface{}), params ...interface{}) uint64

	//循环任务(毫秒) 返回值(定时任务ID)
	LoopDelayTimerByCount(delayTime time.Duration, intervalTime time.Duration, loopCount int, callback func(...interface{}), params ...interface{}) uint64
	//删除定时任务(非线程安全)
	DeleteTimerTask(timerTaskID uint64)
	//删除所有定时任务(非线程安全)
	DeleteAllTimerTask()
}

type Timer

type Timer struct {
	TimerWheelAccuracy int64 //最小时间刻度(毫秒)
	// contains filtered or unexported fields
}

时间桶按毫秒运行

func NewTimer

func NewTimer(opts ...option) *Timer

func (*Timer) DeleteAllTimerTask

func (this *Timer) DeleteAllTimerTask()

删除所有定时任务(非线程安全)

func (*Timer) DeleteTimerTask

func (this *Timer) DeleteTimerTask(timerTaskID uint64)

删除定时任务(非线程安全)

func (*Timer) Len

func (this *Timer) Len() int

func (*Timer) LoopDelayTimer

func (this *Timer) LoopDelayTimer(delayTime time.Duration, intervalTime time.Duration, callback func(...interface{}), params ...interface{}) uint64

循环延时任务 返回值(定时任务ID)

func (*Timer) LoopDelayTimerByCount

func (this *Timer) LoopDelayTimerByCount(delayTime time.Duration, intervalTime time.Duration, loopCount int, callback func(...interface{}), params ...interface{}) uint64

循环任务(毫秒) 返回值(定时任务ID)

func (*Timer) LoopTimer

func (this *Timer) LoopTimer(intervalTime time.Duration, callback func(...interface{}), params ...interface{}) uint64

循环任务 返回值(定时任务ID)

func (*Timer) LoopTimerByCount

func (this *Timer) LoopTimerByCount(intervalTime time.Duration, loopCount int, callback func(...interface{}), params ...interface{}) uint64

循环次数任务 返回值(定时任务ID)

func (*Timer) OnTick

func (this *Timer) OnTick(t time.Time)

func (*Timer) OnceTimer

func (this *Timer) OnceTimer(delayTime time.Duration, callback func(...interface{}), params ...interface{}) uint64

一次任务 返回值(定时任务ID)

func (*Timer) ReStart

func (this *Timer) ReStart(t int64)

重新启动,需要一个时间,(毫秒)

func (*Timer) Start

func (this *Timer) Start()

func (*Timer) Stop

func (this *Timer) Stop()

type TimerTaskType

type TimerTaskType int64

定时任务类型

const (
	TimerTask_one  TimerTaskType = 1 //一次任务
	TimerTask_loop TimerTaskType = 2 //循环任务
)

Jump to

Keyboard shortcuts

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