timer

package
v0.0.0-...-91aa13a Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

基于小根堆的定时器 在github.com\Terry-Mao\goim\libs\time基础上 增加超时函数参数,去掉log4go

Index

Constants

View Source
const (
	Debug = false
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Timer

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

func NewTimer

func NewTimer(num int) (t *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 time.Duration, fn func(interface{}), arg interface{}) (td *TimerData)

Push pushes 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 time.Duration)

Set update timer data.

type TimerData

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

func (*TimerData) Delay

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

func (*TimerData) ExpireString

func (td *TimerData) ExpireString() string

Jump to

Keyboard shortcuts

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