timeutil

package
v0.21.1 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2023 License: AGPL-3.0 Imports: 3 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 struct {
	// contains filtered or unexported fields
}

Ticker is a wrapper around time.Ticker that allows to manually invoke a tick and can be stopped via context.

func NewTicker

func NewTicker(d time.Duration) *Ticker

NewTicker returns a new Ticker instance. If d is 0, the ticker will not be started and only manual ticks will be possible.

func (*Ticker) Duration

func (t *Ticker) Duration() time.Duration

Duration returns the ticker duration.

func (*Ticker) Start

func (t *Ticker) Start(ctx context.Context)

Start starts the ticker.

func (*Ticker) Tick

func (t *Ticker) Tick()

Tick sends a tick to the ticker channel. Ticker must be started before calling this method.

func (*Ticker) TickAt

func (t *Ticker) TickAt(at time.Time)

TickAt sends a tick to the ticker channel with the given time. Ticker must be started before calling this method.

func (*Ticker) TickCh

func (t *Ticker) TickCh() <-chan time.Time

TickCh returns the ticker channel.

type VarTicker added in v0.13.10

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

VarTicker is a wrapper around time.Ticker that allows to manually invoke a tick and can be stopped via context.

It allows to specify multiple durations. The ticker will tick at the specified durations and then repeat the last duration.

func NewVarTicker added in v0.13.10

func NewVarTicker(ds ...time.Duration) *VarTicker

NewVarTicker returns a new VarTicker instance.

func (*VarTicker) Durations added in v0.13.10

func (t *VarTicker) Durations() []time.Duration

Durations returns the ticker durations.

func (*VarTicker) Start added in v0.13.10

func (t *VarTicker) Start(ctx context.Context)

Start starts the ticker.

func (*VarTicker) Tick added in v0.13.10

func (t *VarTicker) Tick()

Tick sends a tick to the ticker channel. Ticker must be started before calling this method.

func (*VarTicker) TickAt added in v0.13.10

func (t *VarTicker) TickAt(at time.Time)

TickAt sends a tick to the ticker channel with the given time. Ticker must be started before calling this method.

func (*VarTicker) TickCh added in v0.13.10

func (t *VarTicker) TickCh() <-chan time.Time

TickCh returns the ticker channel.

Jump to

Keyboard shortcuts

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