timer2

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Debug debug switch
	Debug = false
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry interface {
	AddRef()
	Release() int32
	TimerCallback()
}

type Timer

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

Timer timer.

func NewTimer

func NewTimer(num int) (t *Timer)

NewTimer new a timer. A heap must be initialized before any of the heap operations can be used. Init is idempotent with respect to the heap invariants and may be called whenever the heap invariants may have been invalidated. Its complexity is O(n) where n = h.Len().

func (*Timer) Add

func (t *Timer) Add(expire itime.Duration, fn func()) (td *TimerData)

Add add the element x onto the heap. The complexity is O(log(n)) where n = h.Len().

func (*Timer) Del

func (t *Timer) Del(td *TimerData)

Del removes the element at index i from the heap. The complexity is O(log(n)) where n = h.Len().

func (*Timer) Init

func (t *Timer) Init(num int)

Init init the timer.

func (*Timer) Set

func (t *Timer) Set(td *TimerData, expire itime.Duration)

Set update timer data.

type TimerData

type TimerData struct {
	Key string
	// contains filtered or unexported fields
}

TimerData timer data.

func (*TimerData) Delay

func (td *TimerData) Delay() itime.Duration

Delay delay duration.

func (*TimerData) ExpireString

func (td *TimerData) ExpireString() string

ExpireString expire string.

type TimingWheel

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

func NewTimingWheel

func NewTimingWheel(size int) *TimingWheel

func (*TimingWheel) AddTimer

func (t *TimingWheel) AddTimer(entry Entry, tm int) error

func (*TimingWheel) Start

func (t *TimingWheel) Start()

func (*TimingWheel) Stop

func (t *TimingWheel) Stop()

Jump to

Keyboard shortcuts

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