#include <ExecutionEngine.hpp>
Public Member Functions | |
ExecutionEngine (base::TaskCore *owner=0) | |
base::TaskCore * | getParent () |
base::TaskCore * | getTaskCore () const |
bool | isSelf () const |
virtual bool | process (base::DisposableInterface *c) |
virtual bool | process (base::PortInterface *port) |
virtual bool | removeFunction (base::ExecutableInterface *f) |
virtual bool | removeSelfFunction (base::ExecutableInterface *f) |
virtual bool | runFunction (base::ExecutableInterface *f) |
void | setExceptionTask () |
bool | stopTask (base::TaskCore *task) |
void | waitForMessages (const boost::function< bool(void)> &pred) |
~ExecutionEngine () | |
Public Member Functions inherited from RTT::base::RunnableInterface | |
ActivityInterface * | getActivity () const |
Query for the task this interface is run in. More... | |
virtual os::ThreadInterface * | getThread () const |
virtual void | loop () |
RunnableInterface () | |
virtual void | setActivity (ActivityInterface *task) |
Set the task this interface is run in. More... | |
virtual | ~RunnableInterface () |
Protected Member Functions | |
virtual bool | breakLoop () |
virtual void | finalize () |
virtual bool | hasWork () |
virtual bool | initialize () |
void | processFunctions () |
void | processHooks () |
void | processMessages () |
void | processPortCallbacks () |
virtual void | step () |
void | waitAndProcessMessages (boost::function< bool(void)> const &pred) |
void | waitForMessagesInternal (boost::function< bool(void)> const &pred) |
virtual void | work (RunnableInterface::WorkReason reason) |
Protected Attributes | |
internal::MWSRQueue< base::ExecutableInterface * > * | f_queue |
internal::MWSRQueue< base::DisposableInterface * > * | mqueue |
os::Condition | msg_cond |
os::Mutex | msg_lock |
internal::MWSRQueue< base::PortInterface * > * | port_queue |
base::TaskCore * | taskc |
Additional Inherited Members | |
Public Types inherited from RTT::base::RunnableInterface | |
enum | WorkReason { TimeOut = 0, Trigger, IOReady } |
An execution engine serialises (executes one after the other) the execution of all commands, programs, state machines and incoming 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.
Definition at line 69 of file ExecutionEngine.hpp.
RTT::ExecutionEngine::ExecutionEngine | ( | base::TaskCore * | owner = 0 | ) |
Create an execution engine with a internal::CommandProcessor, scripting::ProgramProcessor and StateMachineProcessor.
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 77 of file ExecutionEngine.cpp.
|
protectedvirtual |
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.
Reimplemented from RTT::base::RunnableInterface.
Definition at line 394 of file ExecutionEngine.cpp.
|
protectedvirtual |
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 427 of file ExecutionEngine.cpp.
TaskCore * RTT::ExecutionEngine::getParent | ( | ) |
The base::TaskCore which created this ExecutionEngine. Identical to getTaskCore().
Definition at line 94 of file ExecutionEngine.cpp.
|
inline |
Returns the owner of this execution engine. Identical to getParent().
Definition at line 93 of file ExecutionEngine.hpp.
|
protectedvirtual |
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.
Reimplemented from RTT::base::RunnableInterface.
Definition at line 202 of file ExecutionEngine.cpp.
|
protectedvirtual |
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 198 of file ExecutionEngine.cpp.
bool RTT::ExecutionEngine::isSelf | ( | ) | const |
Check if the thread that processes messages send to this engine is the same as the calling thread. This method is typically used to check if operation or function calls can be inlined or even must be inlined to resolve potential dead-locks.
Definition at line 287 of file ExecutionEngine.cpp.
|
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().
Definition at line 250 of file ExecutionEngine.cpp.
|
virtual |
Queue and execute (process) a given port callback. The port callback is executed in step() or loop() directly after the queued messages.
Definition at line 265 of file ExecutionEngine.cpp.
|
protected |
Definition at line 98 of file ExecutionEngine.cpp.
|
protected |
Definition at line 360 of file ExecutionEngine.cpp.
|
protected |
Definition at line 207 of file ExecutionEngine.cpp.
|
protected |
Definition at line 232 of file ExecutionEngine.cpp.
|
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 153 of file ExecutionEngine.cpp.
|
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 179 of file ExecutionEngine.cpp.
|
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().
Definition at line 125 of file ExecutionEngine.cpp.
void RTT::ExecutionEngine::setExceptionTask | ( | ) |
Set the 'owner' task in the exception state.
Definition at line 412 of file ExecutionEngine.cpp.
|
protectedvirtual |
Executes (in that order) Messages, Functions and updateHook() functions of this TaskContext and its children.
Implements RTT::base::RunnableInterface.
Definition at line 326 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.
task | The Task calling this function and whose updateHook should no longer be executed. |
Definition at line 401 of file ExecutionEngine.cpp.
|
protected |
Call this if you wish to block on a message arriving in the Execution Engine and execute it.
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.
Definition at line 304 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.
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 279 of file ExecutionEngine.cpp.
|
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.
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.
Definition at line 292 of file ExecutionEngine.cpp.
|
protectedvirtual |
Identical to step() but gives a reason why the function was called. Both step() and work() will be called an equal amount of times, so you need to use only one, but work gives you the reason why.
Reimplemented from RTT::base::RunnableInterface.
Definition at line 330 of file ExecutionEngine.cpp.
|
protected |
Stores all functions we're executing.
Definition at line 224 of file ExecutionEngine.hpp.
|
protected |
Our Message queue
Definition at line 214 of file ExecutionEngine.hpp.
|
protected |
Definition at line 227 of file ExecutionEngine.hpp.
|
protected |
Definition at line 226 of file ExecutionEngine.hpp.
|
protected |
The port callback queue
Definition at line 219 of file ExecutionEngine.hpp.
|
protected |
The parent or 'owner' of this ExecutionEngine, may be null.
Definition at line 209 of file ExecutionEngine.hpp.