chrono

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chrono

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

Chrono can be used to time things around various parts of the application

func NewChrono

func NewChrono() *Chrono

NewChrono creates a `time.Chrono`

func (*Chrono) Elapsed

func (c *Chrono) Elapsed() time.Duration

Elapsed gets the duration elapsed between the time the chronometer was initialised. This method does not reset the internal clock, unless `Chrono.Start` is called.

func (*Chrono) Start

func (c *Chrono) Start()

Start starts the chronometer normally

func (*Chrono) StartContext

func (c *Chrono) StartContext(ctx context.Context) chan time.Duration

StartContext starts the chronometer and ends it whenever the context is terminated returning the duration via a channel

func (*Chrono) StartDeferred

func (c *Chrono) StartDeferred() (func(), chan<- time.Duration)

StartDeferred starts the chronometer and ends it whenever the returned callback is invoked, returning the duration via a channel

type Ticker

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

func NewTicker

func NewTicker(interval time.Duration) *Ticker

func (*Ticker) Tick

func (t *Ticker) Tick(ctx context.Context, fn func())

func (*Ticker) TickErr

func (t *Ticker) TickErr(ctx context.Context, fn func() error) <-chan error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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