Documentation
¶
Overview ¶
Package timing provides utilities for time
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ClearDelayCh is used to stop all ongoing delays. It should not be closed. ClearDelayCh = make(chan struct{}) )
Functions ¶
func DoAfter ¶
DoAfter wraps time calls in a select that will stop events from happening when ClearDelayCh pulls
func DoAfterContext ¶
DoAfterContext executes the function if the context is completed. Clears out if the Delay Channel is cleared.
func FPS ¶
FPS returns the number of frames being processed per second, supposing a time interval from lastTime to now.
func FPSToFrameDelay ¶
FPSToFrameDelay converts a frameRate like 60fps into a delay time between frames
func FPSToNano ¶
FPSToNano converts a framesPerSecond value to the number of nanoseconds that should take place for each frame.
func FrameDelayToFPS ¶
FrameDelayToFPS converts a duration of delay between frames into a frames per second count
Types ¶
type DynamicTicker ¶
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) ForceStep ¶
func (dt *DynamicTicker) ForceStep()
ForceStep is the blocking equivalent to Step. After this is called, it won't return until the ticker has taken the forced step through. A potential use for this is in benchmarking how often the work between ticks can get done.
func (*DynamicTicker) SetTick ¶
func (dt *DynamicTicker) SetTick(tickDuration 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, successive calls to Step will do nothing.
func (*DynamicTicker) Stop ¶
func (dt *DynamicTicker) Stop()
Stop closes all internal channels and stops dt's internal ticker