timewheel

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UnixMilli

func UnixMilli(t time.Time) int64

UnixMilli 毫秒

Types

type TimeWheel

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

TimeWheel 实现一个时间轮定时器,在指定时间运行指定的任务

func New

func New(tick time.Duration, wheelSize int64) *TimeWheel

New 实例化一个时间轮定时器

func (*TimeWheel) AfterFunc

func (tw *TimeWheel) AfterFunc(d time.Duration, f func()) *Timer

AfterFunc

func (*TimeWheel) Start

func (tw *TimeWheel) Start()

func (*TimeWheel) Stop

func (tw *TimeWheel) Stop()

Stop 关闭

type Timer

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

func (*Timer) Reset

func (t *Timer) Reset(d time.Duration) bool

Reset 将定时任务往后延时执行

func (*Timer) Stop

func (t *Timer) Stop() (stopped bool)

Stop 停止任务,当任务已执行时返回false

Jump to

Keyboard shortcuts

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