Documentation
¶
Index ¶
- type CommandHandler
- type CommandHandlerFunc
- type CommandLoop
- type CommandSource
- type Runner
- func (r *Runner[TCommand, Frame]) DrainPendingCommands() bool
- func (r *Runner[TCommand, Frame]) PublishFrame(frame Frame)
- func (r *Runner[TCommand, Frame]) UpdateCommandLoop(loop *CommandLoop[TCommand])
- func (r *Runner[TCommand, Frame]) UpdateVisualBridge(visual *VisualBridge[Frame])
- func (r *Runner[TCommand, Frame]) VisualEnabled() bool
- func (r *Runner[TCommand, Frame]) WaitForCommand(ctx context.Context) bool
- type VisualBridge
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CommandHandler ¶
CommandHandler consumes control commands and determines whether processing should continue.
type CommandHandlerFunc ¶
CommandHandlerFunc adapts a function into a CommandHandler.
func (CommandHandlerFunc[T]) HandleCommand ¶
func (f CommandHandlerFunc[T]) HandleCommand(cmd T) bool
HandleCommand calls the underlying function.
type CommandLoop ¶
type CommandLoop[T any] struct { // contains filtered or unexported fields }
CommandLoop drains and dispatches control commands.
func NewCommandLoop ¶
func NewCommandLoop[T any](source CommandSource[T], handler CommandHandler[T]) *CommandLoop[T]
NewCommandLoop creates a command loop with the given source and handler.
func (*CommandLoop[T]) DrainPending ¶
func (c *CommandLoop[T]) DrainPending() bool
DrainPending pulls all currently available commands from the source until exhaustion or handler termination.
func (*CommandLoop[T]) WaitAndHandle ¶
func (c *CommandLoop[T]) WaitAndHandle(ctx context.Context) bool
WaitAndHandle blocks until a command is available (or context cancellation) and dispatches it.
type CommandSource ¶
type CommandSource[T any] interface { NextCommand() (T, bool) WaitCommand(context.Context) (T, bool) }
CommandSource provides control commands from an external producer.
type Runner ¶
Runner glues command handling and visualization helpers for the main simulator loop.
func NewRunner ¶
func NewRunner[TCommand any, Frame any](loop *CommandLoop[TCommand], visual *VisualBridge[Frame]) *Runner[TCommand, Frame]
NewRunner creates a new Runner instance.
func (*Runner[TCommand, Frame]) DrainPendingCommands ¶
DrainPendingCommands pulls all queued commands through the underlying command loop.
func (*Runner[TCommand, Frame]) PublishFrame ¶
func (r *Runner[TCommand, Frame]) PublishFrame(frame Frame)
PublishFrame emits a frame through the visual bridge if visualization is enabled.
func (*Runner[TCommand, Frame]) UpdateCommandLoop ¶
func (r *Runner[TCommand, Frame]) UpdateCommandLoop(loop *CommandLoop[TCommand])
UpdateCommandLoop swaps the command loop reference.
func (*Runner[TCommand, Frame]) UpdateVisualBridge ¶
func (r *Runner[TCommand, Frame]) UpdateVisualBridge(visual *VisualBridge[Frame])
UpdateVisualBridge swaps the visual bridge reference (e.g., after reset).
func (*Runner[TCommand, Frame]) VisualEnabled ¶
VisualEnabled reports whether visualization bridge is active.
type VisualBridge ¶
type VisualBridge[Frame any] struct { // contains filtered or unexported fields }
VisualBridge coordinates optional visualization publishing.
func NewVisualBridge ¶
func NewVisualBridge[Frame any](headless bool, publish func(Frame)) *VisualBridge[Frame]
NewVisualBridge constructs a bridge with headless flag and publish callback.
func (*VisualBridge[Frame]) IsHeadless ¶
func (v *VisualBridge[Frame]) IsHeadless() bool
IsHeadless reports whether visualization output is disabled.
func (*VisualBridge[Frame]) Publish ¶
func (v *VisualBridge[Frame]) Publish(frame Frame)
Publish emits a frame when visualization is enabled.
func (*VisualBridge[Frame]) SetHeadless ¶
func (v *VisualBridge[Frame]) SetHeadless(headless bool)
SetHeadless updates the headless flag.
func (*VisualBridge[Frame]) UpdatePublisher ¶
func (v *VisualBridge[Frame]) UpdatePublisher(publish func(Frame))
UpdatePublisher resets the publish callback.