sim

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultOptions = []Option{
	WithFramer(stats.CFramer(60*5, stats.FFramer(os.Stdout))),
}

Functions

This section is empty.

Types

type Loop

type Loop struct {
	MinTimePerFrame time.Duration // how long a frame is, frames might take longer than this

	Input input.Capturer // captures user inputs
	TL    timeline.TL    // records user inputs and other info on a timeline
	Model scrub.Scrubber // the simulation model, the things we are controlling/exposing
	// contains filtered or unexported fields
}

Loop repeatedly advances state by recording events on a timeline and scrubbing ahead of those events.

func NewLoop

func NewLoop(tl timeline.TL, model scrub.Scrubber, input input.Capturer, opts ...Option) *Loop

func (*Loop) Advance

func (l *Loop) Advance(ctx context.Context, t time.Time) (err error)

Advance captures outstanding events and scrubs the model to the given time. There is no need to call Advance if you have called Run, it does it for you.

func (*Loop) Run

func (l *Loop) Run(ctx context.Context) error

Run executes the loop for as long as ctx is not cancelled or a critical error has not occurred.

type Option

type Option func(l *Loop)

func WithFramer

func WithFramer(f stats.Framer) Option

Directories

Path Synopsis
Package input provides tools for collecting and processing user input, typically API calls.
Package input provides tools for collecting and processing user input, typically API calls.

Jump to

Keyboard shortcuts

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