timer

package
v0.0.0-...-d098e83 Latest Latest
Warning

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

Go to latest
Published: May 23, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DelMillisecond

func DelMillisecond(t *Millisecond)

DelMillisecond 删除毫秒级定时器(必须与该timerOutChan线性处理.如:在同一个goroutine select中处理数据.)

func DelSecond

func DelSecond(t *Second)

DelSecond 删除秒级定时器(必须与该timerOutChan线性处理.如:在同一个goroutine select中处理数据.)

Types

type Millisecond

type Millisecond struct {
	Arg      interface{} //参数
	Function OnTimerFun  //超时调用的函数
	// contains filtered or unexported fields
}

Millisecond 毫秒级定时器

func (*Millisecond) IsValid

func (p *Millisecond) IsValid() bool

判断是否有效

type OnTimerFun

type OnTimerFun func(arg interface{}) int

OnTimerFun 回调定时器函数(使用协程回调)

type Second

type Second struct {
	Millisecond
}

Second 秒级定时器

type TimerMgr

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

TimerMgr 定时器管理器

func (*TimerMgr) AddMillisecond

func (p *TimerMgr) AddMillisecond(cb OnTimerFun, arg interface{}, expireMillisecond int64) (t *Millisecond)

AddMillisecond 添加毫秒级定时器

func (*TimerMgr) AddSecond

func (p *TimerMgr) AddSecond(cb OnTimerFun, arg interface{}, expire int64) (t *Second)

AddSecond 添加秒级定时器

func (*TimerMgr) Start

func (p *TimerMgr) Start(scanSecondDuration time.Duration, scanMillisecondDuration time.Duration,
	timerOutChan chan<- interface{})

Start scanSecondDuration:扫描秒级定时器, 纳秒间隔(如100000000,则每100毫秒扫描一次秒定时器) Start scanMillisecondDuration:扫描毫秒级定时器, 纳秒间隔(如100000000,则每100毫秒扫描一次毫秒定时器) timerOutChan 是超时事件放置的channel,由外部传入(处理定时器相关数据,必须与该timerOutChan线性处理.如:在同一个goroutine select中处理数据.)

func (*TimerMgr) Stop

func (p *TimerMgr) Stop()

Jump to

Keyboard shortcuts

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