timing

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2018 License: Apache-2.0 Imports: 3 Imported by: 39

Documentation

Overview

Package timing provides utilities for time

Index

Constants

This section is empty.

Variables

View Source
var (
	// ClearDelayCh is used to stop all ongoing delays
	ClearDelayCh = make(chan bool)
)

Functions

func DoAfter

func DoAfter(d time.Duration, f func())

DoAfter wraps time calls in a select that will stop events from happening when ClearDelayCh pulls

func FPS

func FPS(lastTime, now time.Time) float64

FPS returns the number of frames being processed per second, supposing a time interval from lastTime to now.

func FPSToDuration

func FPSToDuration(FrameRate int) time.Duration

FPSToDuration converts a frameRate like 60fps into a duration

func FPSToNano

func FPSToNano(fps float64) int64

FPSToNano converts a framesPerSecond value to the number of nanoseconds that should take place for each frame.

Types

type DynamicTicker

type DynamicTicker struct {
	C chan time.Time
	// contains filtered or unexported fields
}

A DynamicTicker is a ticker which can be sent signals in the form of durations to change how often it ticks.

func NewDynamicTicker

func NewDynamicTicker() *DynamicTicker

NewDynamicTicker returns a null-initialized dynamic ticker

func (*DynamicTicker) SetTick

func (dt *DynamicTicker) SetTick(d time.Duration)

SetTick changes the rate at which a dynamic ticker ticks

func (*DynamicTicker) Step

func (dt *DynamicTicker) Step()

Step will force the dynamic ticker to tick, once. If the forced tick is not received, multiple calls to step will do nothing.

func (*DynamicTicker) Stop

func (dt *DynamicTicker) Stop()

Stop closes all internal channels and stops dt's internal ticker

Jump to

Keyboard shortcuts

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