clock

package
v1.0.0-alpha.18 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2021 License: Apache-2.0, MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Clock

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

func New

func New(opt ...Option) *Clock

func (*Clock) Advance

func (c *Clock) Advance(t time.Time)

func (*Clock) After

func (c *Clock) After(d time.Duration, callback func()) (cancel func())

func (*Clock) Ticker

func (c *Clock) Ticker(d time.Duration, callback func()) (cancel func())

func (*Clock) Timestep

func (c *Clock) Timestep() time.Duration

type Option

type Option func(c *Clock)

func WithTick

func WithTick(d time.Duration) Option

WithTick sets the time-step for thes simulation clock. This is effectively precision with which the resulting clock is able to measure time. A smaller time-step is more CPU-efficient. If d < 0, defaults to millisecond precision.

There is a trade-off between performance and precision such that a larger tick interval will reduce the load on the CPU when there are many events in the clock, at the expense of a

Jump to

Keyboard shortcuts

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