util

package
v0.0.0-...-a534134 Latest Latest
Warning

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

Go to latest
Published: May 6, 2019 License: GPL-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	B  Bytes = iota
	KB       = 1 << (10 * iota)
	MB
	GB
	TB
)

Variables

This section is empty.

Functions

func ByteFmt

func ByteFmt(bytes float64) string

Types

type Bytes

type Bytes float64

type DeprecationError

type DeprecationError struct{}

func (DeprecationError) Error

func (d DeprecationError) Error() string

type Ticker

type Ticker struct {
	// Duration represents frequently the ticker should tick
	Duration time.Duration
	// Ticks are sent down this channel
	C <-chan time.Time

	// If set to true, a tick is sent down the channel immediately
	InstaTick bool
	// contains filtered or unexported fields
}

Ticker behaves like time.Ticker, but also supports stopping and restarting without destroying the initial ticker, as well as sending the first tick immediately

func NewTicker

func NewTicker(d time.Duration, insta bool) *Ticker

NewTicker returns a new Ticker which ticks repeatedly at the given duration. If insta is set to true, it will send a tick down its' channel on instantiation

func (*Ticker) Kill

func (t *Ticker) Kill()

Kill kills the ticker, preventing it from being started again. The Ticker will panic if Start() is called after Kill() Kill may be called when the ticker is in any state (other than killed)

func (*Ticker) Start

func (t *Ticker) Start()

Start starts the Ticker, or resumes it from a stopped state. It will panic if called while the Ticker is in a started or killed state.

func (*Ticker) Stop

func (t *Ticker) Stop()

Stop stops the ticker, with the intention of restarting it again. The outbound channel is not closed. If you are intending not to use the Ticker again, call Kill() to properly free resources. Stop may be called from any state.

Jump to

Keyboard shortcuts

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