timer

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TimeForever = time.Duration(math.MaxInt64)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Item

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

Item is a heap timer item.

func (*Item) Reset

func (it *Item) Reset(timeout time.Duration)

Reset resets timer.

func (*Item) ResetUntil

func (it *Item) ResetUntil(t time.Time)

ResetUntil resets timer.

func (*Item) Stop

func (it *Item) Stop()

Stop stops a timer.

type Timer

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

func New

func New(name string, executor func(f func())) *Timer

func (*Timer) After

func (t *Timer) After(timeout time.Duration) <-chan time.Time

After used as time.After.

func (*Timer) AfterFunc

func (t *Timer) AfterFunc(timeout time.Duration, f func()) *Item

AfterFunc used as time.AfterFunc.

func (*Timer) Async

func (t *Timer) Async(f func())

Async executes f in another goroutine.

func (*Timer) Start

func (t *Timer) Start()

Start .

func (*Timer) Stop

func (t *Timer) Stop()

Stop .

func (*Timer) UntilFunc

func (t *Timer) UntilFunc(expire time.Time, f func()) *Item

UntilFunc call f when time expire.

type TimerGroup

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

func NewGroup

func NewGroup(name string, size int, executor func(f func())) *TimerGroup

NewGroup creates a TimerGroup.

func (*TimerGroup) After

func (tg *TimerGroup) After(timeout time.Duration) <-chan time.Time

After used as time.After.

func (*TimerGroup) AfterFunc

func (tg *TimerGroup) AfterFunc(timeout time.Duration, f func()) *Item

AfterFunc used as time.AfterFunc.

func (*TimerGroup) Async

func (tg *TimerGroup) Async(f func())

Async executes f in another goroutine.

func (*TimerGroup) NextIndex

func (tg *TimerGroup) NextIndex() uint32

NextIndex returns next timer index.

func (*TimerGroup) NextTimer

func (tg *TimerGroup) NextTimer() *Timer

NextTimer returns next timer.

func (*TimerGroup) Start

func (tg *TimerGroup) Start()

Start .

func (*TimerGroup) Stop

func (tg *TimerGroup) Stop()

Stop .

Jump to

Keyboard shortcuts

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