NRP Core  1.4.1
EventLoopInterface Class Referenceabstract

Manages simulation loop. Runs physics and brain interface, and synchronizes them via Transfer Functions. More...

#include <event_loop_interface.h>

Inheritance diagram for EventLoopInterface:
EventLoop EventLoopEngine

Public Member Functions

virtual ~EventLoopInterface ()=default
 
 EventLoopInterface ()=delete
 
 EventLoopInterface (std::chrono::milliseconds timestep, std::chrono::milliseconds timestepThres)
 Constructor. More...
 
virtual void initialize ()
 Initialize loop. More...
 
void runLoopOnce (const std::chrono::time_point< std::chrono::steady_clock > &startTime)
 Run a single loop. More...
 
void runLoop (std::chrono::milliseconds timeout)
 Run loop. More...
 
void runLoopAsync (std::chrono::milliseconds timeout=std::chrono::milliseconds(0), bool doInit=false)
 Run loop in a thread. More...
 
void stopLoop ()
 Stop loop. More...
 
void shutdown ()
 Shutdown loop. More...
 
bool isRunning ()
 Returns true if the event loop is currently running, false otherwise. More...
 
void waitForLoopEnd ()
 Blocks execution until the loop reaches timeout. More...
 

Protected Member Functions

virtual void initializeCB ()=0
 Initialize loop. More...
 
virtual void runLoopCB ()=0
 Execute actions which must be performed every loop. More...
 
virtual void shutdownCB ()=0
 Shutdown loop. More...
 
bool isRunningNotAsync ()
 Internal isRunning function. More...
 

Protected Attributes

std::chrono::milliseconds _timestep
 timestep of the event loop
More...
 
std::chrono::milliseconds _timestepThres
 allowed time deviation in event loop timestep execution before printing a warning message More...
 
std::chrono::milliseconds _currentTime = std::chrono::milliseconds(0)
 current time clock
More...
 
unsigned long _iterations = 0L
 stores the number of times the loop has been run More...
 

Detailed Description

Manages simulation loop. Runs physics and brain interface, and synchronizes them via Transfer Functions.

Constructor & Destructor Documentation

◆ ~EventLoopInterface()

virtual EventLoopInterface::~EventLoopInterface ( )
virtualdefault

◆ EventLoopInterface() [1/2]

EventLoopInterface::EventLoopInterface ( )
delete

◆ EventLoopInterface() [2/2]

EventLoopInterface::EventLoopInterface ( std::chrono::milliseconds  timestep,
std::chrono::milliseconds  timestepThres 
)

Constructor.

Member Function Documentation

◆ initialize()

void EventLoopInterface::initialize ( )
virtual

Initialize loop.

◆ initializeCB()

virtual void EventLoopInterface::initializeCB ( )
protectedpure virtual

Initialize loop.

Implemented in EventLoop, and EventLoopEngine.

◆ isRunning()

bool EventLoopInterface::isRunning ( )

Returns true if the event loop is currently running, false otherwise.

It is intended to be used together with runLoopAsync

◆ isRunningNotAsync()

bool EventLoopInterface::isRunningNotAsync ( )
protected

Internal isRunning function.

It can be used from threads, even when runLoopAsync was not used

◆ runLoop()

void EventLoopInterface::runLoop ( std::chrono::milliseconds  timeout)

Run loop.

◆ runLoopAsync()

void EventLoopInterface::runLoopAsync ( std::chrono::milliseconds  timeout = std::chrono::milliseconds(0),
bool  doInit = false 
)

Run loop in a thread.

Parameters
timeouttime in seconds the loop will be run for
doInitif 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

◆ runLoopCB()

virtual void EventLoopInterface::runLoopCB ( )
protectedpure virtual

Execute actions which must be performed every loop.

Implemented in EventLoop, and EventLoopEngine.

◆ runLoopOnce()

void EventLoopInterface::runLoopOnce ( const std::chrono::time_point< std::chrono::steady_clock > &  startTime)

Run a single loop.

◆ shutdown()

void EventLoopInterface::shutdown ( )

Shutdown loop.

◆ shutdownCB()

virtual void EventLoopInterface::shutdownCB ( )
protectedpure virtual

Shutdown loop.

Implemented in EventLoop, and EventLoopEngine.

◆ stopLoop()

void EventLoopInterface::stopLoop ( )

Stop loop.

It is intended to be used together with runLoopAsync

◆ waitForLoopEnd()

void EventLoopInterface::waitForLoopEnd ( )

Blocks execution until the loop reaches timeout.

It is intended to be used together with runLoopAsync

Member Data Documentation

◆ _currentTime

std::chrono::milliseconds EventLoopInterface::_currentTime = std::chrono::milliseconds(0)
protected

current time clock

◆ _iterations

unsigned long EventLoopInterface::_iterations = 0L
protected

stores the number of times the loop has been run

◆ _timestep

std::chrono::milliseconds EventLoopInterface::_timestep
protected

timestep of the event loop

◆ _timestepThres

std::chrono::milliseconds EventLoopInterface::_timestepThres
protected

allowed time deviation in event loop timestep execution before printing a warning message


The documentation for this class was generated from the following files: