timer: github.com/ivahaev/timer Index | Files

package timer

import "github.com/ivahaev/timer"

Index

Package Files

timer.go

type Timer Uses

type Timer struct {
    C <-chan time.Time
    // contains filtered or unexported fields
}

The Timer type represents a single event. When the Timer expires, the current time will be sent on C, unless the Timer was created by AfterFunc. A Timer must be created with NewTimer or AfterFunc.

func AfterFunc Uses

func AfterFunc(d time.Duration, f func()) *Timer

AfterFunc waits after calling its Start method for the duration to elapse and then calls f in its own goroutine. It returns a Timer that can be used to cancel the call using its Stop method, or pause using its Pause method

func NewTimer Uses

func NewTimer(d time.Duration) *Timer

NewTimer creates a new Timer. It returns a Timer that can be used to cancel the call using its Stop method, or pause using its Pause method

func (*Timer) Pause Uses

func (t *Timer) Pause() bool

Pause pauses current timer until Start method will be called. Next Start call will wait rest of duration.

func (*Timer) Start Uses

func (t *Timer) Start() bool

Start starts Timer that will send the current time on its channel after at least duration d.

func (*Timer) Stop Uses

func (t *Timer) Stop() bool

Stop prevents the Timer from firing. It returns true if the call stops the timer, false if the timer has already expired or been stopped. Stop does not close the channel, to prevent a read from the channel succeeding incorrectly.

Package timer imports 1 packages (graph) and is imported by 1 packages. Updated 2017-02-09. Refresh now. Tools for package owners.