timeutil

package
v2.15.2-prerelease Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2023 License: MIT Imports: 3 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Future

func Future(duration time.Duration) time.Time

Future provides a time.Time duration into the future from now

func Past

func Past(duration time.Duration) time.Time

Past provides a time.Time duration into the past from now

Types

type RunStop

type RunStop interface {
	Run()
	Running() bool
	Stop()
}

RunStop exposes a functions for running, stopping, and querying status of presumably a background job.

func RunEvery

func RunEvery(f func(), wait time.Duration) RunStop

RunEvery wait duration. Use returned channel to stop.

type Ticker

type Ticker interface {
	// Start this ticker sending time on it's channel.
	Start() Ticker
	// Reset this ticker by creating a new channel and sending time on it.
	Reset()
	// Stop this ticker and release underlying resources.
	Stop()
	// SetPeriod of this ticker to the passed duration. The ticker must be restarted
	// after this change.
	SetPeriod(period time.Duration)
	// Channel that is used to send the 'ticks'
	Channel() <-chan time.Time
}

Ticker sends the time, after a period, on it's channel once started.

func NewTicker

func NewTicker(period time.Duration) Ticker

NewTicker returns a new Ticker containing a channel that will send the time with a period specified by the duration argument once Started. It adjusts the intervals or drops ticks to make up for slow receivers. The duration d must be greater than zero; if not, NewTicker will panic. Stop the ticker to release associated resources.

Jump to

Keyboard shortcuts

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