timer

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Node

type Node struct {
	// contains filtered or unexported fields
}

Node 时间轮槽的链表节点

type TimeWheel

type TimeWheel struct {
	// contains filtered or unexported fields
}

TimeWheel 时间轮

type Timer

type Timer struct {
	// contains filtered or unexported fields
}

Timer 定时器

func NewTimer

func NewTimer(tick time.Duration, num int) *Timer

NewTimer 创建一个指定槽数量和最小粒度的定时器

func (*Timer) Register

func (t *Timer) Register(tType TimerType, delay time.Duration, handler func(args any), args any) (string, error)

Register 注册一个定时器,返回timerID

func (*Timer) Remove

func (t *Timer) Remove(timerID string) error

Remove 删除指定定时器

func (*Timer) Reset

func (t *Timer) Reset(timerID string) error

Reset 重新设置定时器

func (*Timer) Stop

func (t *Timer) Stop()

Stop 停止

type TimerType

type TimerType uint8

TimerType 定时器类型

const (
	Single     TimerType = 1 //单次
	Repetition TimerType = 2 //循环

)

Jump to

Keyboard shortcuts

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