|
Motion Master 6.0.0-alpha.86
Next-generation motion control software
|
Interface for work executed once per game loop cycle. More...
#include <cyclic_task.h>
Public Member Functions | |
| virtual | ~CyclicTask ()=default |
| Virtual destructor. | |
| virtual void | execute (const CycleContext &ctx) noexcept=0 |
| Called once per cycle, after the exchange of process data and device parameters updated. | |
Interface for work executed once per game loop cycle.
Implementations must be non-blocking and must not allocate heap memory or perform I/O on the calling thread. Any async work (e.g. pushing data to a WebSocket) must be handed off to another thread via a lock-free channel.
Tasks are registered with GameLoop::addTask() before run() is called and are owned by the caller (the composition root). GameLoop holds non-owning pointers, so a task must outlive every call to run().
|
virtualdefault |
Virtual destructor.
|
pure virtualnoexcept |
Called once per cycle, after the exchange of process data and device parameters updated.
Must return before the next cycle deadline. Blocking here stalls the entire RT loop.
**noexcept states the contract in the type.** This project returns std::expected and throws nothing, but a task is ordinary C++ and may call something that throws. Left implicit, such an exception would unwind out of the RT loop and reach std::terminate from wherever the stack happened to be. Declared here, the throw terminates at its own site instead, so the report names the line that threw rather than the loop that ran it. A task that can fail reports it through its own channel — a value it publishes, or a log line — never by throwing.
| ctx | Per-cycle timing context (grid index + skipped count). Tasks that act only on the freshest state may ignore it. |
Implemented in mm::node::ProcessDataCyclicTask, and mm::example::ExampleCyclicTask.