time

package
v0.0.85 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2020 License: MIT Imports: 1 Imported by: 6

Documentation

Index

Constants

View Source
const DefaultInitDuration = 5 * time.Millisecond
View Source
const DefaultMaxDuration = 1 * time.Second
View Source
const DefaultStepTimes = 2
View Source
const ZeroDuration = 0

Variables

This section is empty.

Functions

func After

func After(d time.Duration) <-chan time.Time

Types

type Delay

type Delay struct {
	InitDuration      time.Duration
	MaxDuration       time.Duration
	DelayAgainHandler func(delay time.Duration) time.Duration
	// contains filtered or unexported fields
}

func NewDefaultDelay

func NewDefaultDelay() *Delay

func (*Delay) Delay

func (d *Delay) Delay() <-chan time.Time

func (*Delay) DelayFunc

func (d *Delay) DelayFunc(f func()) *Timer

func (*Delay) Duration

func (d *Delay) Duration() time.Duration

func (*Delay) Reset

func (d *Delay) Reset()

func (*Delay) Sleep

func (d *Delay) Sleep()

func (*Delay) Update

func (d *Delay) Update()

type Timer

type Timer struct {
	*time.Timer
}

https://github.com/golang/go/issues/27169 Timer to fix time: Timer.Stop documentation example easily leads to deadlocks

func AfterFunc

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

func NewTimer

func NewTimer(d time.Duration) *Timer

func WrapTimer

func WrapTimer(t *time.Timer) *Timer

func (*Timer) Reset

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

Reset changes the timer to expire after duration d. Reset can be invoked anytime, which enhances std time.Reset Reset == std [Stop + drain + Reset] It returns true if the timer had been active, false if the timer had expired or been stopped.

func (*Timer) Stop

func (t *Timer) Stop() bool

Stop prevents the Timer from firing, with the channel drained. Stop ensures the channel is empty after a call to Stop. Stop == std [Stop + drain] 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.

Directories

Path Synopsis
The key observation and some code (shr) is borrowed from golang.org/x/time/rate/rate.go
The key observation and some code (shr) is borrowed from golang.org/x/time/rate/rate.go

Jump to

Keyboard shortcuts

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