timer

package
v0.0.0-...-7847555 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2018 License: CC0-1.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Timer

type Timer struct {
	C <-chan struct{} // The timer channel
	// contains filtered or unexported fields
}

Timer is a timer t that fires exactly once. The channel t.C will be closed when the timer fires. The duration after which the timer should fire can be decreased via the t.Duration method. You can call t.Duration multiple times, the first duration to expire will cause the timer to fire. If you stop using the timer before it has fired, call t.Stop to prevent resources leaking.

func New

func New() *Timer

New returns a new timer.

func (*Timer) Duration

func (t *Timer) Duration(d time.Duration)

Duration adds a duration after which the timer will have fired. The first duration to expire will fire the timer.

func (*Timer) Stop

func (t *Timer) Stop() (didStop bool)

Stop stops the timer. This will cause the channel t.C to be closed, freeing any background resources used by the timer. Stop returns true if the call stops the timer, false if the timer has already expired or been stopped.

Jump to

Keyboard shortcuts

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