clock

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2025 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckInterval

func CheckInterval(clk Clock, since Time, interval Ticks) bool

CheckInterval reports whether number of ticks, including current one, that have passed since given logical time, is multiple of given positive interval.

CheckInterval always returns false if time is zero.

Types

type Clock

type Clock interface {

	// Now returns current logical time. It is guaranteed that result is greater than previous one
	// after the next update start and is equal to previous one during one update.
	Now() Time
}

Clock of logical time.

type Ticks

type Ticks int64

Ticks represents number of logical time units. One tick usually corresponds to single application update.

const Tick Ticks = 1

Tick represents single tick.

type Time

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

Time represents number of ticks, including the first one, counted from start of logical time.

Zero Time precedes start of logical time and represents both zero and any negative number of ticks.

func At

func At(ticks Ticks) Time

At returns Time representing given number of ticks.

func (Time) Add

func (t Time) Add(d Ticks) Time

Add returns sum of t and d.

func (Time) IsZero

func (t Time) IsZero() bool

IsZero reports whether t is zero.

func (Time) String

func (t Time) String() string

String implements the fmt.Stringer interface.

func (Time) Sub

func (t Time) Sub(u Time) Ticks

Sub returns difference of t and u.

func (Time) Ticks

func (t Time) Ticks() Ticks

Ticks returns number of ticks represented by t.

Directories

Path Synopsis
driver

Jump to

Keyboard shortcuts

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