gtime

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TimerWheel

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

TimerWheel 时钟轮

func NewTimerWheel

func NewTimerWheel(opt ...TwOption) *TimerWheel

NewTimerWheel create a instance of TimerWheel with given options

func (*TimerWheel) After

func (t *TimerWheel) After(interval time.Duration, times int) (chan struct{}, string, error)

After add a timer using the given interval time

func (*TimerWheel) AfterFunc

func (t *TimerWheel) AfterFunc(interval time.Duration, times int, f func()) (string, error)

AfterFunc add a timer callback function which will trigger after the given interval time and trigger times

func (*TimerWheel) Cancel

func (t *TimerWheel) Cancel(timerID string) error

Cancel the timer

func (*TimerWheel) Start

func (t *TimerWheel) Start()

Start a ticker for check expired items

func (*TimerWheel) Stop

func (t *TimerWheel) Stop()

Stop the ticker

type TwOption

type TwOption struct {
	TickDuration time.Duration `json:"tick_duration" yaml:"tick_duration"`
	WheelCount   int           `json:"wheel_count" yaml:"wheel_count"`
}

TwOption is the configuration of TimerWheel

Jump to

Keyboard shortcuts

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