timer

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 10, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TIME_NEAR_SHIFT  = 8
	TIME_NEAR        = (1 << TIME_NEAR_SHIFT)
	TIME_LEVEL_SHIFT = 6
	TIME_LEVEL       = (1 << TIME_LEVEL_SHIFT)
	TIME_NEAR_MASK   = (TIME_NEAR - 1)
	TIME_LEVEL_MASK  = (TIME_LEVEL - 1)
	TICK_INTERVAL    = 10 * time.Millisecond
)

Variables

This section is empty.

Functions

func RegisterTimer

func RegisterTimer(id *int64, duration time.Duration, handle TimerHandle, opts ...OpOption)

func StopTimer

func StopTimer(id *int64)

func StoreTimerId

func StoreTimerId(id *int64, val int64) bool

Types

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

这个队列可以换成无锁队列

type Op

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

type OpOption

type OpOption func(*Op)

func WithOnce

func WithOnce() OpOption

type Timer

type Timer struct {
	// contains filtered or unexported fields
}
var (
	TIMER *Timer
)

func (*Timer) Add

func (t *Timer) Add(id *int64, time uint32, handle TimerHandle, opts ...OpOption) *TimerNode

添加一个定时器

func (*Timer) Delete

func (t *Timer) Delete(id *int64)

删除一个定时器

func (*Timer) Init

func (t *Timer) Init()

创建一个定时器

type TimerHandle

type TimerHandle func()

type TimerNode

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

func (*TimerNode) LoadId

func (t *TimerNode) LoadId() int64

Jump to

Keyboard shortcuts

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