time

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2016 License: BSD-2-Clause, MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exponential

func Exponential(prev time.Duration) time.Duration

Exponential defines the strategy of having linearly increasing tick intervals.

func ExponentialJitter

func ExponentialJitter(prev time.Duration) time.Duration

ExponentialJitter defines the strategy of having linearly increasing random tick intervals.

func Linear

func Linear(prev time.Duration) time.Duration

Linear defines the strategy of having constant tick intervals.

func LinearJitter

func LinearJitter(prev time.Duration) time.Duration

LinearJitter defines the strategy of having random tick intervals.

func Tick

func Tick(strategy IntervalStrategy) <-chan time.Time

Tick is a convenience wrapper for NewTicker providing access to the ticking channel only. While Tick is useful for clients that have no need to shut down the Ticker, be aware that without a way to shut it down the underlying Ticker cannot be recovered by the garbage collector; it "leaks".

Types

type IntervalStrategy

type IntervalStrategy func(prev time.Duration) (next time.Duration)

IntervalStrategy defines an interval strategy function.

type Ticker

type Ticker struct {
	C chan time.Time
	// contains filtered or unexported fields
}

Ticker is similar to package time's Ticker but instead of choosing tick interval durations, tick interval strategies and maximum value are chosen.

func NewTicker

func NewTicker(strategy IntervalStrategy) *Ticker

NewTicker returns a new Ticker containing a channel that will send the time in interval periods specified by an interval strategy. Stop the ticker to release associated resources.

func (*Ticker) Stop

func (t *Ticker) Stop()

Stop turns off a ticker. After Stop, no more ticks will be sent. Stop does not close the channel, to prevent a read from the channel succeeding incorrectly.

Jump to

Keyboard shortcuts

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