RTT::ExecutionEngine Class Reference
[Execution Engine]

#include <ExecutionEngine.hpp>

Inheritance diagram for RTT::ExecutionEngine:
Inheritance graph
[legend]

List of all members.

Public Member Functions

virtual void addChild (base::TaskCore *tc)
virtual void addChild (base::TaskCore *tc)
 ExecutionEngine (base::TaskCore *owner=0)
 ExecutionEngine (base::TaskCore *owner=0)
base::TaskCoregetParent ()
base::TaskCoregetParent ()
base::TaskCoregetTaskCore () const
base::TaskCoregetTaskCore () const
virtual bool process (base::DisposableInterface *c)
virtual bool process (base::DisposableInterface *c)
virtual void removeChild (base::TaskCore *tc)
virtual void removeChild (base::TaskCore *tc)
virtual bool removeFunction (base::ExecutableInterface *f)
virtual bool removeFunction (base::ExecutableInterface *f)
virtual bool removeSelfFunction (base::ExecutableInterface *f)
virtual bool removeSelfFunction (base::ExecutableInterface *f)
virtual bool runFunction (base::ExecutableInterface *f)
virtual bool runFunction (base::ExecutableInterface *f)
bool stopTask (base::TaskCore *task)
bool stopTask (base::TaskCore *task)
void waitForFunctions (const boost::function< bool(void)> &pred)
void waitForFunctions (const boost::function< bool(void)> &pred)
void waitForMessages (const boost::function< bool(void)> &pred)
void waitForMessages (const boost::function< bool(void)> &pred)
 ~ExecutionEngine ()
 ~ExecutionEngine ()

Protected Member Functions

virtual bool breakLoop ()
virtual bool breakLoop ()
virtual void finalize ()
virtual void finalize ()
virtual bool hasWork ()
virtual bool hasWork ()
virtual bool initialize ()
virtual bool initialize ()
void processChildren ()
void processChildren ()
void processFunctions ()
void processFunctions ()
void processMessages ()
void processMessages ()
virtual void step ()
virtual void step ()
void waitAndProcessFunctions (boost::function< bool(void)> const &pred)
void waitAndProcessFunctions (boost::function< bool(void)> const &pred)
void waitAndProcessMessages (boost::function< bool(void)> const &pred)
void waitAndProcessMessages (boost::function< bool(void)> const &pred)
void waitForMessagesInternal (boost::function< bool(void)> const &pred)
void waitForMessagesInternal (boost::function< bool(void)> const &pred)

Protected Attributes

std::vector< base::TaskCore * > children
internal::MWSRQueue
< base::ExecutableInterface * > * 
f_queue
internal::MWSRQueue
< base::DisposableInterface * > * 
mqueue
os::Condition msg_cond
os::Mutex msg_lock
base::TaskCoretaskc

Detailed Description

An execution engine serialises (executes one after the other) the execution of all commands, programs, state machines and incomming events for a task. Any function executing in the same execution engine is guaranteed to be thread-safe with respect to other functions executing in the same execution engine.

The ExecutionEngine bundles a internal::CommandProcessor, scripting::ProgramProcessor, scripting::StateMachineProcessor and MessageProcessor.

Changing the Execution Policy
One can subclass this class in order to change the run-time behaviour. Use base::TaskCore::setExecutionEngine in order to install a new ExecutionEngine in a component. All Members of this class are protected and thus accessible in a subclass.

Definition at line 70 of file install/include/rtt/ExecutionEngine.hpp.


Constructor & Destructor Documentation

RTT::ExecutionEngine::ExecutionEngine ( base::TaskCore owner = 0  ) 

Create an execution engine with a internal::CommandProcessor, scripting::ProgramProcessor and StateMachineProcessor.

Parameters:
owner The base::TaskCore in which this execution engine executes. It may be null, in that case no base::TaskCore owns this execution engine.

Definition at line 69 of file ExecutionEngine.cpp.

RTT::ExecutionEngine::~ExecutionEngine (  ) 

Definition at line 76 of file ExecutionEngine.cpp.

RTT::ExecutionEngine::ExecutionEngine ( base::TaskCore owner = 0  ) 

Create an execution engine with a internal::CommandProcessor, scripting::ProgramProcessor and StateMachineProcessor.

Parameters:
owner The base::TaskCore in which this execution engine executes. It may be null, in that case no base::TaskCore owns this execution engine.
RTT::ExecutionEngine::~ExecutionEngine (  ) 

Member Function Documentation

virtual void RTT::ExecutionEngine::addChild ( base::TaskCore tc  )  [virtual]

Add a base::TaskCore to execute.

void RTT::ExecutionEngine::addChild ( base::TaskCore tc  )  [virtual]

Add a base::TaskCore to execute.

Definition at line 103 of file ExecutionEngine.cpp.

virtual bool RTT::ExecutionEngine::breakLoop (  )  [protected, virtual]

This method is called by the framework to break out of the loop() method. Reimplement this method to signal loop() to return and return true on success. When this method is not reimplemented by you, it will always return false, denoting that the loop can not be broken. If breakLoop() returns true, the caller will wait until loop() returns.

Returns:
true if the loop could be notified to return.

Reimplemented from RTT::base::RunnableInterface.

bool RTT::ExecutionEngine::breakLoop (  )  [protected, virtual]

This method is called by the framework to break out of the loop() method. Reimplement this method to signal loop() to return and return true on success. When this method is not reimplemented by you, it will always return false, denoting that the loop can not be broken. If breakLoop() returns true, the caller will wait until loop() returns.

Returns:
true if the loop could be notified to return.

Reimplemented from RTT::base::RunnableInterface.

Definition at line 386 of file ExecutionEngine.cpp.

virtual void RTT::ExecutionEngine::finalize (  )  [protected, virtual]

The method that will be called after the last periodical execution of step() ( or non periodical execution of loop() ), when the RunnableInterface is stopped.

Implements RTT::base::RunnableInterface.

void RTT::ExecutionEngine::finalize (  )  [protected, virtual]

The method that will be called after the last periodical execution of step() ( or non periodical execution of loop() ), when the RunnableInterface is stopped.

Implements RTT::base::RunnableInterface.

Definition at line 408 of file ExecutionEngine.cpp.

base::TaskCore* RTT::ExecutionEngine::getParent (  ) 

The base::TaskCore which created this ExecutionEngine.

TaskCore * RTT::ExecutionEngine::getParent (  ) 

The base::TaskCore which created this ExecutionEngine.

Definition at line 99 of file ExecutionEngine.cpp.

base::TaskCore* RTT::ExecutionEngine::getTaskCore (  )  const [inline]

Returns the owner of this execution engine.

Definition at line 80 of file rtt/ExecutionEngine.hpp.

base::TaskCore* RTT::ExecutionEngine::getTaskCore (  )  const [inline]

Returns the owner of this execution engine.

Definition at line 80 of file install/include/rtt/ExecutionEngine.hpp.

virtual bool RTT::ExecutionEngine::hasWork (  )  [protected, virtual]

This method is for 'intelligent' activity implementations that wish to see if it is required to call step() (again). By default, false is returned. You should only return true in case there is a temporary reason to (re-)run step.

Returns:
true if this object should be run.
See also:
extras::SequentialActivity implementation to see how this can be of use.

Reimplemented from RTT::base::RunnableInterface.

bool RTT::ExecutionEngine::hasWork (  )  [protected, virtual]

This method is for 'intelligent' activity implementations that wish to see if it is required to call step() (again). By default, false is returned. You should only return true in case there is a temporary reason to (re-)run step.

Returns:
true if this object should be run.
See also:
extras::SequentialActivity implementation to see how this can be of use.

Reimplemented from RTT::base::RunnableInterface.

Definition at line 211 of file ExecutionEngine.cpp.

virtual bool RTT::ExecutionEngine::initialize (  )  [protected, virtual]

The method that will be called before the first periodical execution of step() ( or non periodical execution of loop() ), when the thread is started.

Implements RTT::base::RunnableInterface.

bool RTT::ExecutionEngine::initialize (  )  [protected, virtual]

The method that will be called before the first periodical execution of step() ( or non periodical execution of loop() ), when the thread is started.

Implements RTT::base::RunnableInterface.

Definition at line 206 of file ExecutionEngine.cpp.

virtual bool RTT::ExecutionEngine::process ( base::DisposableInterface c  )  [virtual]

Queue and execute (process) a given message. The message is executed in step() or loop() directly after all other queued ActionInterface objects. The constructor parameter queue_size limits how many messages can be queued in between step()s or loop().

Returns:
true if the message got accepted, false otherwise.
false when the MessageProcessor is not running or does not accept messages.
See also:
acceptMessages
bool RTT::ExecutionEngine::process ( base::DisposableInterface c  )  [virtual]

Queue and execute (process) a given message. The message is executed in step() or loop() directly after all other queued ActionInterface objects. The constructor parameter queue_size limits how many messages can be queued in between step()s or loop().

Returns:
true if the message got accepted, false otherwise.
false when the MessageProcessor is not running or does not accept messages.
See also:
acceptMessages

Definition at line 238 of file ExecutionEngine.cpp.

void RTT::ExecutionEngine::processChildren (  )  [protected]
void RTT::ExecutionEngine::processChildren (  )  [protected]

Definition at line 324 of file ExecutionEngine.cpp.

void RTT::ExecutionEngine::processFunctions (  )  [protected]
void RTT::ExecutionEngine::processFunctions (  )  [protected]

Definition at line 113 of file ExecutionEngine.cpp.

void RTT::ExecutionEngine::processMessages (  )  [protected]
void RTT::ExecutionEngine::processMessages (  )  [protected]

Definition at line 216 of file ExecutionEngine.cpp.

virtual void RTT::ExecutionEngine::removeChild ( base::TaskCore tc  )  [virtual]

Remove a base::TaskCore from execution.

void RTT::ExecutionEngine::removeChild ( base::TaskCore tc  )  [virtual]

Remove a base::TaskCore from execution.

Definition at line 107 of file ExecutionEngine.cpp.

virtual bool RTT::ExecutionEngine::removeFunction ( base::ExecutableInterface f  )  [virtual]

Remove a running function added with runFunction. This method is only required if the function is to be destroyed and is still present in the Engine.

bool RTT::ExecutionEngine::removeFunction ( base::ExecutableInterface f  )  [virtual]

Remove a running function added with runFunction. This method is only required if the function is to be destroyed and is still present in the Engine.

Definition at line 161 of file ExecutionEngine.cpp.

virtual bool RTT::ExecutionEngine::removeSelfFunction ( base::ExecutableInterface f  )  [virtual]

Self-removal for a running function added with runFunction. You must call this variant in case you want yourself to be removed. Equivalent to returning false in ExecutableInterface::execute().

bool RTT::ExecutionEngine::removeSelfFunction ( base::ExecutableInterface f  )  [virtual]

Self-removal for a running function added with runFunction. You must call this variant in case you want yourself to be removed. Equivalent to returning false in ExecutableInterface::execute().

Definition at line 187 of file ExecutionEngine.cpp.

virtual bool RTT::ExecutionEngine::runFunction ( base::ExecutableInterface f  )  [virtual]

Run a given function in step() or loop(). The function may only be destroyed after the ExecutionEngine is stopped or removeFunction() was invoked. The number of functions the Processor can run in parallel can be increased with setMaxFunctions().

Returns:
false if the Engine is not running or the 'pending' queue is full.
See also:
removeFunction(), setMaxFunctions()
bool RTT::ExecutionEngine::runFunction ( base::ExecutableInterface f  )  [virtual]

Run a given function in step() or loop(). The function may only be destroyed after the ExecutionEngine is stopped or removeFunction() was invoked. The number of functions the Processor can run in parallel can be increased with setMaxFunctions().

Returns:
false if the Engine is not running or the 'pending' queue is full.
See also:
removeFunction(), setMaxFunctions()

Definition at line 132 of file ExecutionEngine.cpp.

virtual void RTT::ExecutionEngine::step (  )  [protected, virtual]

Executes (in that order) Messages, Functions and updateHook() functions of this TaskContext and its children.

Implements RTT::base::RunnableInterface.

void RTT::ExecutionEngine::step (  )  [protected, virtual]

Executes (in that order) Messages, Functions and updateHook() functions of this TaskContext and its children.

Implements RTT::base::RunnableInterface.

Definition at line 318 of file ExecutionEngine.cpp.

bool RTT::ExecutionEngine::stopTask ( base::TaskCore task  ) 

Stops executing the updateHook of task. This is an explicit synchronisation point, which guarantees that updateHook is no longer executed when this function returns true.

Parameters:
task The Task calling this function and whose updateHook should no longer be executed.
Returns:
true if it's updateHook() is no longer being executed, false otherwise.
bool RTT::ExecutionEngine::stopTask ( base::TaskCore task  ) 

Stops executing the updateHook of task. This is an explicit synchronisation point, which guarantees that updateHook is no longer executed when this function returns true.

Parameters:
task The Task calling this function and whose updateHook should no longer be executed.
Returns:
true if it's updateHook() is no longer being executed, false otherwise.

Definition at line 396 of file ExecutionEngine.cpp.

void RTT::ExecutionEngine::waitAndProcessFunctions ( boost::function< bool(void)> const &  pred  )  [protected]

Call this if you wish to block on a function completing in the Execution Engine and execute it.

Parameters:
pred As long as !pred() waits and processes functions. If pred() == true when entering this function, then no functions will be processed and this function returns immediately.

This function is for internal use only and is required for asynchronous function invocations.

Note:
waitAndProcessFunctions will call in turn this->processFunctions() and may as a consequence recurse if we get an asynchronous call-back.
void RTT::ExecutionEngine::waitAndProcessFunctions ( boost::function< bool(void)> const &  pred  )  [protected]

Call this if you wish to block on a function completing in the Execution Engine and execute it.

Parameters:
pred As long as !pred() waits and processes functions. If pred() == true when entering this function, then no functions will be processed and this function returns immediately.

This function is for internal use only and is required for asynchronous function invocations.

Note:
waitAndProcessFunctions will call in turn this->processFunctions() and may as a consequence recurse if we get an asynchronous call-back.

Definition at line 300 of file ExecutionEngine.cpp.

void RTT::ExecutionEngine::waitAndProcessMessages ( boost::function< bool(void)> const &  pred  )  [protected]

Call this if you wish to block on a message arriving in the Execution Engine and execute it.

Parameters:
pred As long as !pred() waits and processes messages. If pred() == true when entering this function, then no messages will be processed and this function returns immediately.

This function is for internal use only and is required for asynchronous method invocations.

Note:
waitAndProcessMessages will call in turn this->processMessages() and may as a consequence recurse if we get an asynchronous call-back.
void RTT::ExecutionEngine::waitAndProcessMessages ( boost::function< bool(void)> const &  pred  )  [protected]

Call this if you wish to block on a message arriving in the Execution Engine and execute it.

Parameters:
pred As long as !pred() waits and processes messages. If pred() == true when entering this function, then no messages will be processed and this function returns immediately.

This function is for internal use only and is required for asynchronous method invocations.

Note:
waitAndProcessMessages will call in turn this->processMessages() and may as a consequence recurse if we get an asynchronous call-back.

Definition at line 282 of file ExecutionEngine.cpp.

void RTT::ExecutionEngine::waitForFunctions ( const boost::function< bool(void)> &  pred  ) 

Call this if you wish to block on a function completing in the Execution Engine. Each time a function completes, waitForFunctions will return when pred() returns true.

Parameters:
pred As long as !pred() blocks the calling thread. If pred() == true when entering this function, returns immediately.

This function is for internal use only and is required for asynchronous function invocations.

void RTT::ExecutionEngine::waitForFunctions ( const boost::function< bool(void)> &  pred  ) 

Call this if you wish to block on a function completing in the Execution Engine. Each time a function completes, waitForFunctions will return when pred() returns true.

Parameters:
pred As long as !pred() blocks the calling thread. If pred() == true when entering this function, returns immediately.

This function is for internal use only and is required for asynchronous function invocations.

Definition at line 261 of file ExecutionEngine.cpp.

void RTT::ExecutionEngine::waitForMessages ( const boost::function< bool(void)> &  pred  ) 

Call this if you wish to block on a message arriving in the Execution Engine. Each time one or more messages are processed, waitForMessages will return when pred() returns true.

Parameters:
pred As long as !pred() blocks the calling thread. If pred() == true when entering this function, returns immediately.

This function is for internal use only and is required for asynchronous method invocations.

void RTT::ExecutionEngine::waitForMessages ( const boost::function< bool(void)> &  pred  ) 

Call this if you wish to block on a message arriving in the Execution Engine. Each time one or more messages are processed, waitForMessages will return when pred() returns true.

Parameters:
pred As long as !pred() blocks the calling thread. If pred() == true when entering this function, returns immediately.

This function is for internal use only and is required for asynchronous method invocations.

Definition at line 252 of file ExecutionEngine.cpp.

void RTT::ExecutionEngine::waitForMessagesInternal ( boost::function< bool(void)> const &  pred  )  [protected]

Call this if you wish to block on a message arriving in the Execution Engine. Each time one or more messages are processed, waitForMessages will return when pred() returns true.

Parameters:
pred As long as !pred() blocks the calling thread. If pred() == true when entering this function, the returns immediately.

This function is for internal use only and is required for asynchronous method invocations.

Note:
waitForMessages requires another thread to execute processMessages() and may therefor not be called from within the component's Thread. Use waitAndProcessMessages() instead.
void RTT::ExecutionEngine::waitForMessagesInternal ( boost::function< bool(void)> const &  pred  )  [protected]

Call this if you wish to block on a message arriving in the Execution Engine. Each time one or more messages are processed, waitForMessages will return when pred() returns true.

Parameters:
pred As long as !pred() blocks the calling thread. If pred() == true when entering this function, the returns immediately.

This function is for internal use only and is required for asynchronous method invocations.

Note:
waitForMessages requires another thread to execute processMessages() and may therefor not be called from within the component's Thread. Use waitAndProcessMessages() instead.

Definition at line 270 of file ExecutionEngine.cpp.


Member Data Documentation

std::vector< base::TaskCore * > RTT::ExecutionEngine::children [protected]

Definition at line 204 of file install/include/rtt/ExecutionEngine.hpp.

Stores all functions we're executing.

Definition at line 209 of file install/include/rtt/ExecutionEngine.hpp.

Our Message queue

Definition at line 202 of file install/include/rtt/ExecutionEngine.hpp.

Definition at line 212 of file install/include/rtt/ExecutionEngine.hpp.

Definition at line 211 of file install/include/rtt/ExecutionEngine.hpp.

The parent or 'owner' of this ExecutionEngine, may be null.

Definition at line 197 of file install/include/rtt/ExecutionEngine.hpp.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


rtt
Author(s): RTT Developers
autogenerated on Fri Jan 11 09:49:47 2013