timewheel

package
v0.6.21 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Job

type Job func(interface{})

Job 延时任务回调函数

type Task

type Task struct {
	Forever bool //永久性任务
	// contains filtered or unexported fields
}

Task 延时任务

type TimeWheel

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

TimeWheel 时间轮

func New

func New(interval time.Duration, slotNum int, job Job) *TimeWheel

New 创建时间轮

func (*TimeWheel) AddTimer

func (tw *TimeWheel) AddTimer(delay time.Duration, key interface{}, forever bool, data interface{})

AddTimer 添加定时器 key为定时器唯一标识

func (*TimeWheel) RemoveTimer

func (tw *TimeWheel) RemoveTimer(key interface{})

RemoveTimer 删除定时器 key为添加定时器时传递的定时器唯一标识

func (*TimeWheel) Start

func (tw *TimeWheel) Start()

Start 启动时间轮

func (*TimeWheel) Stop

func (tw *TimeWheel) Stop()

Stop 停止时间轮

Jump to

Keyboard shortcuts

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