timer

package
v1.10.1 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2024 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 StopTimer

func StopTimer(id *int64)

func StoreTimerId

func StoreTimerId(id *int64, val int64) bool

Types

type ISimpleTimer

type ISimpleTimer interface {
	SetInterval(int)
	CheckTimer() bool
	Start()
	Stop()
	GetTimerCount() int
	IsActived() bool
}
type LinkList struct {
	// contains filtered or unexported fields
}

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

type Op

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

先搞清楚下面的单位 1秒=1000毫秒 milliseconds 1毫秒=1000微秒 microseconds 1微秒=1000纳秒 nanoseconds 整个timer中毫秒的精度都是10ms, 也就是说毫秒的一个三个位,但是最小的位被丢弃

type OpOption

type OpOption func(*Op)

先搞清楚下面的单位 1秒=1000毫秒 milliseconds 1毫秒=1000微秒 microseconds 1微秒=1000纳秒 nanoseconds 整个timer中毫秒的精度都是10ms, 也就是说毫秒的一个三个位,但是最小的位被丢弃

func WithOnce

func WithOnce() OpOption

type SimpleTimer

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

func NewSimpleTimer

func NewSimpleTimer(interval int) *SimpleTimer

func (*SimpleTimer) CheckTimer

func (s *SimpleTimer) CheckTimer() bool

func (*SimpleTimer) GetTimerCount

func (s *SimpleTimer) GetTimerCount() int

func (*SimpleTimer) IsActived

func (s *SimpleTimer) IsActived() bool

func (*SimpleTimer) SetInterval

func (s *SimpleTimer) SetInterval(interval int)

func (*SimpleTimer) Start

func (s *SimpleTimer) Start()

func (*SimpleTimer) Stop

func (s *SimpleTimer) Stop()

type Timer

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

先搞清楚下面的单位 1秒=1000毫秒 milliseconds 1毫秒=1000微秒 microseconds 1微秒=1000纳秒 nanoseconds 整个timer中毫秒的精度都是10ms, 也就是说毫秒的一个三个位,但是最小的位被丢弃

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()

先搞清楚下面的单位 1秒=1000毫秒 milliseconds 1毫秒=1000微秒 microseconds 1微秒=1000纳秒 nanoseconds 整个timer中毫秒的精度都是10ms, 也就是说毫秒的一个三个位,但是最小的位被丢弃

type TimerNode

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

先搞清楚下面的单位 1秒=1000毫秒 milliseconds 1毫秒=1000微秒 microseconds 1微秒=1000纳秒 nanoseconds 整个timer中毫秒的精度都是10ms, 也就是说毫秒的一个三个位,但是最小的位被丢弃

func RegisterTimer

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

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