Help us shape the future of Go! Take the 2026 Go Developer Survey

impetus

package module
v0.0.0-...-51d4e78 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2019 License: MIT Imports: 1 Imported by: 1

README

impetus

impetus is a very light wrapper over time.Ticker that causes the first tick to be instant

Usage :

The usage is very simple and the same as using a time.Ticker.

    ticker  := impetus.NewImmediateTicker(5 * time.Seconds)
    for range ticker.C{
        fmt.Println("tick doesn't wait for 5 seconds")
    }

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ImmediateTicker

type ImmediateTicker struct {
	*time.Ticker
}

ImmediateTicker is a wrapper a ticker that produces the first tick instantaneously because. time.Ticker waits for the time.Duration it started with before the first tick.

func NewImmediateTicker

func NewImmediateTicker(duration time.Duration) *ImmediateTicker

NewImmediateTicker creates a new instance of ImmediateTicker by wrapping Ticker around it

func (*ImmediateTicker) Stop

func (b *ImmediateTicker) Stop()

Stop Gracefully closes the wrapped ticker and the wrapping ticker

Jump to

Keyboard shortcuts

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