class EventLoopInterface¶
Overview¶
Manages simulation loop. Runs physics and brain interface, and synchronizes them via Transfer Functions. More…
#include <event_loop_interface.h> class EventLoopInterface { public: // construction EventLoopInterface(); EventLoopInterface( std::chrono::milliseconds timestep, std::chrono::milliseconds timestepThres ); // methods virtual void initialize(); void runLoopOnce(const std::chrono::time_point<std::chrono::steady_clock>& startTime); void runLoop(std::chrono::milliseconds timeout); void runLoopAsync( std::chrono::milliseconds timeout = std::chrono::milliseconds(0), bool doInit = false ); void stopLoop(); void shutdown(); bool isRunning(); void waitForLoopEnd(); }; // direct descendants class EventLoop; class EventLoopEngine;
Detailed Documentation¶
Manages simulation loop. Runs physics and brain interface, and synchronizes them via Transfer Functions.
Construction¶
EventLoopInterface( std::chrono::milliseconds timestep, std::chrono::milliseconds timestepThres )
Constructor.
Methods¶
virtual void initialize()
Initialize loop.
void runLoopOnce(const std::chrono::time_point<std::chrono::steady_clock>& startTime)
Run a single loop.
void runLoop(std::chrono::milliseconds timeout)
Run loop.
void runLoopAsync( std::chrono::milliseconds timeout = std::chrono::milliseconds(0), bool doInit = false )
Run loop in a thread.
Parameters:
timeout |
time in seconds the loop will be run for |
doInit |
if true, Initialize is executed before runLoop, also in the same thread. This is useful in cases where initialize needs to interact with the main thread |
void stopLoop()
Stop loop.
It is intended to be used together with runLoopAsync
void shutdown()
Shutdown loop.
bool isRunning()
Returns true if the event loop is currently running, false otherwise.
It is intended to be used together with runLoopAsync
void waitForLoopEnd()
Blocks execution until the loop reaches timeout.
It is intended to be used together with runLoopAsync