timeutil

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 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.

Jump to

Keyboard shortcuts

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