timer

package
v1.1.23 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func After

func After(interval time.Duration, randomDeviation time.Duration, task func(), opts ...timingwheel.Option) *timingwheel.Timer

After wrap timingwheel.TimingWheel .AfterFunc

@param interval 间隔
@param randomDeviation 随机方差范围 interval = interval + randomDeviation*[-0.5,0.5)
@param task
@param opts

func Cron

func Cron(interval time.Duration, randomDeviation time.Duration, task func(), opts ...timingwheel.Option) *timingwheel.Timer

Cron wrap timingwheel.TimingWheel .Cron

@param interval 间隔
@param randomDeviation 随机方差范围,interval=interval+randomDeviation*[-0.5,0.5)
@param task
@param opts

func InitPool added in v1.0.2

func InitPool(size int, interval time.Duration, numSlots int)

InitPool 初始化 pool

@param size 池子容量
@param interval 时间轮帧间隔
@param numSlots 时间槽数量 时间轮第一层总时长=interval*numSlots

func TimeWheelInstance

func TimeWheelInstance() *timingwheel.TimingWheel

TimeWheelInstance 从 pool 里获取一个时间轮

@return *TimeWheel

Types

type TimeWheelPool

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

TimeWheelPool 时间轮池子

func NewTimeWheelPool

func NewTimeWheelPool(size int, interval time.Duration, numSlots int) *TimeWheelPool

NewTimeWheelPool

@param size 池子容量
@param interval 时间轮帧间隔
@param numSlots 时间槽数量 时间轮第一层总时长=interval*numSlots
@return *TimeWheelPool

func (*TimeWheelPool) Get

Get 顺序获取下一个时间轮

@receiver tp
@return *TimeWheel

func (*TimeWheelPool) GetRandom

func (tp *TimeWheelPool) GetRandom() *timingwheel.TimingWheel

GetRandom 随机获取一个时间轮

@receiver tp
@return *TimeWheel

func (*TimeWheelPool) Start

func (tp *TimeWheelPool) Start()

Start 启动

@receiver tp

func (*TimeWheelPool) Stop

func (tp *TimeWheelPool) Stop()

Stop 停止

@receiver tp

Jump to

Keyboard shortcuts

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