impl

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClock

func NewClock() pkg.Clock

func NewTicker

func NewTicker(d time.Duration) pkg.Ticker

func NewTimer

func NewTimer(d time.Duration) pkg.Timer

func NewTimerFunc

func NewTimerFunc(d time.Duration, f func()) pkg.Timer

Types

type Clock

type Clock struct{}

Clock implements a real-time clock by simply wrapping the time package functions.

func (*Clock) After

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

func (*Clock) AfterFunc

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

func (*Clock) Now

func (c *Clock) Now() time.Time

func (*Clock) Since

func (c *Clock) Since(t time.Time) time.Duration

func (*Clock) Sleep

func (c *Clock) Sleep(d time.Duration)

func (*Clock) Tick

func (c *Clock) Tick(d time.Duration) <-chan time.Time

func (*Clock) Ticker

func (c *Clock) Ticker(d time.Duration) pkg.Ticker

func (*Clock) Timer

func (c *Clock) Timer(d time.Duration) pkg.Timer

func (*Clock) Until

func (c *Clock) Until(t time.Time) time.Duration

func (*Clock) WithDeadline

func (c *Clock) WithDeadline(parent context.Context, d time.Time) (context.Context, context.CancelFunc)

func (*Clock) WithTimeout

func (c *Clock) WithTimeout(parent context.Context, t time.Duration) (context.Context, context.CancelFunc)

type Ticker

type Ticker struct {
	// contains filtered or unexported fields
}

Ticker holds a channel that receives "ticks" at regular intervals.

func (*Ticker) Chan

func (t *Ticker) Chan() <-chan time.Time

func (*Ticker) Reset

func (t *Ticker) Reset(dur time.Duration)

Reset resets the ticker to a new duration.

func (*Ticker) Stop

func (t *Ticker) Stop()

Stop turns off the ticker.

type Timer

type Timer struct {
	// contains filtered or unexported fields
}

Timer represents a single event. The current time will be sent on C, unless the timer was created by AfterFunc.

func (*Timer) Chan

func (t *Timer) Chan() <-chan time.Time

func (*Timer) Reset

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

Reset changes the expiry time of the timer

func (*Timer) Stop

func (t *Timer) Stop() bool

Stop turns off the ticker.

Jump to

Keyboard shortcuts

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