ticker

package
v0.0.0-...-a2a6e8a Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Ticker

type Ticker interface {
	Start()
	Stop()
	ReSet()
}

type Timer

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

Timer represents a single event. When the Timer expires, the given task will be executed.

func (*Timer) Stop

func (t *Timer) Stop() bool

Stop prevents the Timer from firing. It returns true if the call stops the ticker, false if the ticker has already expired or been stopped.

If the ticker t has already expired and the t.task has been started in its own goroutine; Stop does not wait for t.task to complete before returning. If the caller needs to know whether t.task is completed, it must coordinate with t.task explicitly.

type TimerParams

type TimerParams struct {
	Seconds int
	Args    interface{}
	Cb      timerCB
}

type TimingWheel

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

TimingWheel is an implementation of Hierarchical Timing Wheels.

func NewTimingWheel

func NewTimingWheel(tick time.Duration, wheelSize int64) *TimingWheel

NewTimingWheel creates an instance of TimingWheel with the given tick and wheelSize.

func (*TimingWheel) AfterFunc

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

AfterFunc waits for the duration to elapse and then calls f in its own goroutine. It returns a Timer that can be used to cancel the call using its Stop method.

func (*TimingWheel) Start

func (tw *TimingWheel) Start()

Start starts the current timing wheel.

func (*TimingWheel) Stop

func (tw *TimingWheel) Stop()

Stop stops the current timing wheel.

If there is any ticker's task being running in its own goroutine, Stop does not wait for the task to complete before returning. If the caller needs to know whether the task is completed, it must coordinate with the task explicitly.

type WbTimer

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

func StartTimer

func StartTimer(params TimerParams) *WbTimer

func (*WbTimer) CheckTimer

func (r *WbTimer) CheckTimer(limit int64) bool

检查 ticker 是否还生效

func (*WbTimer) GetTS

func (r *WbTimer) GetTS() int64

func (*WbTimer) ReStart

func (r *WbTimer) ReStart()

func (*WbTimer) Reset

func (r *WbTimer) Reset()

func (*WbTimer) Stop

func (r *WbTimer) Stop()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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