Orocos Real-Time Toolkit
2.9.0
|
A process-wide execution engine that processes every asynchronous operation that is not being processed by a TaskContext. More...
#include <rtt/internal/GlobalEngine.hpp>
Public Types | |
enum | WorkReason { TimeOut = 0, Trigger, IOReady } |
Public Member Functions | |
base::TaskCore * | getParent () |
The base::TaskCore which created this ExecutionEngine. More... | |
base::TaskCore * | getTaskCore () const |
Returns the owner of this execution engine. More... | |
virtual bool | process (base::DisposableInterface *c) |
Queue and execute (process) a given message. More... | |
virtual bool | process (base::PortInterface *port) |
Queue and execute (process) a given port callback. More... | |
virtual bool | runFunction (base::ExecutableInterface *f) |
Run a given function in step() or loop(). More... | |
virtual bool | removeFunction (base::ExecutableInterface *f) |
Remove a running function added with runFunction. More... | |
virtual bool | removeSelfFunction (base::ExecutableInterface *f) |
Self-removal for a running function added with runFunction. More... | |
void | waitForMessages (const boost::function< bool(void)> &pred) |
Call this if you wish to block on a message arriving in the Execution Engine. More... | |
bool | stopTask (base::TaskCore *task) |
Stops executing the updateHook of task. More... | |
void | setExceptionTask () |
Set the 'owner' task in the exception state. More... | |
void | setMaster (ExecutionEngine *master) |
Set the master ExecutionEngine. More... | |
virtual void | setActivity (base::ActivityInterface *task) |
Overridden version of RTT::base::RunnableInterface::setActivity(). More... | |
virtual os::ThreadInterface * | getThread () const |
Get the thread that processes messages send to this engine. More... | |
bool | isSelf () const |
Check if the thread that processes messages send to this engine is the same as the calling thread. More... | |
virtual void | loop () |
The method that will be executed once when this class is run in a non periodic Activity. More... | |
ActivityInterface * | getActivity () const |
Query for the task this interface is run in. More... | |
Static Public Member Functions | |
static RTT_API ExecutionEngine * | Instance () |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. This is kept (instead of using default parameters) for ABI compatibility. More... | |
static RTT_API ExecutionEngine * | Instance (int scheduler, int priority=os::LowestPriority, unsigned cpu_affinity=0) |
static RTT_API void | Release () |
Protected Member Functions | |
void | waitForMessagesInternal (boost::function< bool(void)> const &pred) |
Call this if you wish to block on a message arriving in the Execution Engine. More... | |
void | waitAndProcessMessages (boost::function< bool(void)> const &pred) |
Call this if you wish to block on a message arriving in the Execution Engine and execute it. More... | |
void | processMessages () |
void | processPortCallbacks () |
void | processFunctions () |
void | processHooks () |
virtual bool | initialize () |
The method that will be called before the first periodical execution of step() ( or non periodical execution of loop() ), when the thread is started. More... | |
virtual void | step () |
Executes (in that order) Messages, Functions and updateHook() functions of this TaskContext and its children. More... | |
virtual void | work (RunnableInterface::WorkReason reason) |
Identical to step() but gives a reason why the function was called. More... | |
virtual bool | breakLoop () |
This method is called by the framework to break out of the loop() method. More... | |
virtual void | finalize () |
The method that will be called after the last periodical execution of step() ( or non periodical execution of loop() ), when the RunnableInterface is stopped. More... | |
virtual bool | hasWork () |
This method is for 'intelligent' activity implementations that wish to see if it is required to call step() (again). More... | |
Protected Attributes | |
base::TaskCore * | taskc |
The parent or 'owner' of this ExecutionEngine, may be null. More... | |
internal::MWSRQueue< base::DisposableInterface * > * | mqueue |
Our Message queue. More... | |
internal::MWSRQueue< base::PortInterface * > * | port_queue |
The port callback queue. More... | |
internal::MWSRQueue< base::ExecutableInterface * > * | f_queue |
Stores all functions we're executing. More... | |
os::Mutex | msg_lock |
os::Condition | msg_cond |
ExecutionEngine * | mmaster |
A master ExecutionEngine which should process our messages. More... | |
A process-wide execution engine that processes every asynchronous operation that is not being processed by a TaskContext.
In practice, this only occurs when a client does a send() on an OperationCaller which calls an Operation with the ClientThread policy.
Definition at line 60 of file GlobalEngine.hpp.
|
inherited |
Enumerator | |
---|---|
TimeOut | |
Trigger | |
IOReady |
Definition at line 76 of file RunnableInterface.hpp.
|
protectedvirtualinherited |
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 427 of file ExecutionEngine.cpp.
References RTT::base::TaskCore::breakUpdateHook(), and RTT::ExecutionEngine::taskc.
|
protectedvirtualinherited |
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 460 of file ExecutionEngine.cpp.
|
inlineinherited |
Query for the task this interface is run in.
Zero denotes that no task is present to run it, and hence no detailed information is available.
Definition at line 175 of file RunnableInterface.hpp.
Referenced by RTT::base::TaskCore::activate(), RTT::scripting::StateMachine::createEventTransition(), RTT::base::TaskCore::fatal(), RTT::TaskContext::getActivity(), RTT::base::TaskCore::getCpuAffinity(), RTT::base::TaskCore::getPeriod(), RTT::base::TaskCore::isActive(), RTT::ExecutionEngine::process(), RTT::ExecutionEngine::removeFunction(), RTT::ExecutionEngine::runFunction(), RTT::base::TaskCore::setCpuAffinity(), RTT::base::TaskCore::setPeriod(), RTT::ExecutionEngine::stopTask(), RTT::base::TaskCore::trigger(), and RTT::base::TaskCore::update().
|
inherited |
The base::TaskCore which created this ExecutionEngine.
Identical to getTaskCore().
Definition at line 94 of file ExecutionEngine.cpp.
References RTT::ExecutionEngine::taskc.
Referenced by RTT::extras::IRQActivity::start(), and RTT::base::TaskCore::~TaskCore().
|
inlineinherited |
Returns the owner of this execution engine.
Identical to getParent().
Definition at line 93 of file ExecutionEngine.hpp.
|
virtualinherited |
Get the thread that processes messages send to this engine.
Reimplemented from RTT::base::RunnableInterface.
Definition at line 312 of file ExecutionEngine.cpp.
References RTT::base::RunnableInterface::getThread(), RTT::ExecutionEngine::getThread(), and RTT::ExecutionEngine::mmaster.
Referenced by RTT::ExecutionEngine::getThread(), and RTT::ExecutionEngine::isSelf().
|
protectedvirtualinherited |
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 194 of file ExecutionEngine.cpp.
References RTT::ExecutionEngine::mqueue.
|
protectedvirtualinherited |
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 190 of file ExecutionEngine.cpp.
|
inlinestatic |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. This is kept (instead of using default parameters) for ABI compatibility.
Definition at line 70 of file GlobalEngine.hpp.
References Instance(), RTT::os::LowestPriority, ORO_SCHED_OTHER, Release(), and RTT_API.
Referenced by RTT::scripting::ScriptingService::evalInternal(), RTT::base::OperationCallerInterface::getMessageProcessor(), Instance(), RTT::scripting::Parser::Parser(), RTT::scripting::FunctionFactory::produce(), and RTT::scripting::ScriptParser::ScriptParser().
|
static |
Definition at line 61 of file GlobalEngine.cpp.
|
inherited |
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 320 of file ExecutionEngine.cpp.
References RTT::ExecutionEngine::getThread(), and RTT::os::ThreadInterface::isSelf().
Referenced by RTT::scripting::CallFunction::execute(), RTT::base::OperationCallerInterface::isSend(), and RTT::ExecutionEngine::waitForMessages().
|
virtualinherited |
The method that will be executed once when this class is run in a non periodic Activity.
The default implementation calls step() once.
Reimplemented in RTT::os::Timer.
Definition at line 60 of file CoreRunnableInterface.cpp.
References RTT::base::RunnableInterface::step().
Referenced by RTT::extras::SlaveActivity::execute(), and RTT::Activity::loop().
|
virtualinherited |
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 242 of file ExecutionEngine.cpp.
References RTT::os::Condition::broadcast(), RTT::base::TaskCore::FatalError, RTT::base::RunnableInterface::getActivity(), RTT::ExecutionEngine::mmaster, RTT::ExecutionEngine::mqueue, RTT::ExecutionEngine::msg_cond, RTT::base::TaskCore::mTaskState, RTT::ExecutionEngine::process(), RTT::ExecutionEngine::taskc, and RTT::base::ActivityInterface::trigger().
Referenced by RTT::internal::LocalOperationCallerImpl< FunctionT >::do_send(), RTT::scripting::CallFunction::execute(), RTT::internal::LocalOperationCallerImpl< FunctionT >::executeAndDispose(), RTT::internal::FusedMSignal< Signature >::invoke(), RTT::ExecutionEngine::process(), RTT::ExecutionEngine::removeFunction(), and RTT::TaskContext::stop().
|
virtualinherited |
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 262 of file ExecutionEngine.cpp.
References RTT::base::TaskCore::FatalError, RTT::base::RunnableInterface::getActivity(), RTT::ExecutionEngine::mmaster, RTT::base::TaskCore::mTaskState, RTT::ExecutionEngine::port_queue, RTT::ExecutionEngine::process(), RTT::ExecutionEngine::taskc, and RTT::base::ActivityInterface::trigger().
|
protectedinherited |
Definition at line 98 of file ExecutionEngine.cpp.
References RTT::os::Condition::broadcast(), RTT::base::ExecutableInterface::execute(), RTT::ExecutionEngine::f_queue, RTT::ExecutionEngine::msg_cond, and RTT::base::ExecutableInterface::unloaded().
Referenced by RTT::ExecutionEngine::work().
|
protectedinherited |
Definition at line 395 of file ExecutionEngine.cpp.
References CATCH, CATCH_ALL, RTT::Error, RTT::base::TaskCore::errorHook(), RTT::base::TaskCore::exception(), RTT::base::TaskCore::mTaskState, RTT::base::TaskCore::Running, RTT::base::TaskCore::RunTimeError, RTT::ExecutionEngine::taskc, TRY, and RTT::base::TaskCore::updateHook().
Referenced by RTT::ExecutionEngine::work().
|
protectedinherited |
Definition at line 199 of file ExecutionEngine.cpp.
References RTT::os::Condition::broadcast(), RTT::base::DisposableInterface::executeAndDispose(), RTT::ExecutionEngine::mqueue, RTT::ExecutionEngine::msg_cond, and RTT::ExecutionEngine::msg_lock.
Referenced by RTT::ExecutionEngine::waitAndProcessMessages(), and RTT::ExecutionEngine::work().
|
protectedinherited |
Definition at line 224 of file ExecutionEngine.cpp.
References RTT::TaskContext::dataOnPortCallback(), RTT::ExecutionEngine::port_queue, and RTT::ExecutionEngine::taskc.
Referenced by RTT::ExecutionEngine::work().
|
static |
Definition at line 67 of file GlobalEngine.cpp.
Referenced by __os_exit(), and Instance().
|
virtualinherited |
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 145 of file ExecutionEngine.cpp.
References RTT::RemoveMsg::done(), RTT::RemoveMsg::found, RTT::base::RunnableInterface::getActivity(), RTT::base::ActivityInterface::isActive(), RTT::base::ExecutableInterface::isLoaded(), RTT::ExecutionEngine::process(), RTT::ExecutionEngine::removeSelfFunction(), RTT::base::ExecutableInterface::unloaded(), and RTT::ExecutionEngine::waitForMessages().
Referenced by RTT::scripting::ScriptingService::recursiveUnloadStateMachine(), RTT::scripting::CmdFunction::reset(), RTT::scripting::ScriptingService::unloadProgram(), RTT::scripting::FunctionGraph::~FunctionGraph(), and RTT::scripting::StateMachine::~StateMachine().
|
virtualinherited |
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 171 of file ExecutionEngine.cpp.
References RTT::ExecutionEngine::f_queue.
Referenced by RTT::RemoveMsg::executeAndDispose(), and RTT::ExecutionEngine::removeFunction().
|
virtualinherited |
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 117 of file ExecutionEngine.cpp.
References RTT::ExecutionEngine::f_queue, RTT::base::TaskCore::FatalError, RTT::base::RunnableInterface::getActivity(), RTT::base::ExecutableInterface::loaded(), RTT::base::TaskCore::mTaskState, and RTT::ExecutionEngine::taskc.
Referenced by RTT::scripting::CallFunction::execute(), RTT::scripting::CmdFunction::get(), RTT::scripting::ScriptingService::loadFunctions(), RTT::scripting::ScriptingService::loadProgram(), and RTT::scripting::ScriptingService::recursiveLoadStateMachine().
|
virtualinherited |
Overridden version of RTT::base::RunnableInterface::setActivity().
This version will also set the master ExecutionEngine if the new activity is a SlaveActivity that runs an ExecutionEngine.
task | The ActivityInterface running this interface. |
Reimplemented from RTT::base::RunnableInterface.
Definition at line 300 of file ExecutionEngine.cpp.
References RTT::extras::SlaveActivity::getMaster(), RTT::base::ActivityInterface::getRunner(), RTT::base::RunnableInterface::setActivity(), and RTT::ExecutionEngine::setMaster().
|
inherited |
Set the 'owner' task in the exception state.
Definition at line 445 of file ExecutionEngine.cpp.
References RTT::Error, RTT::base::TaskCore::exception(), RTT::TaskContext::getName(), and RTT::ExecutionEngine::taskc.
Referenced by RTT::base::OperationCallerInterface::reportError().
|
inherited |
Set the master ExecutionEngine.
If set, all incoming messages are forwarded to the master.
master | The new master ExecutionEngine. |
Definition at line 295 of file ExecutionEngine.cpp.
References RTT::ExecutionEngine::mmaster.
Referenced by RTT::ExecutionEngine::setActivity().
|
protectedvirtualinherited |
Executes (in that order) Messages, Functions and updateHook() functions of this TaskContext and its children.
Implements RTT::base::RunnableInterface.
Definition at line 361 of file ExecutionEngine.cpp.
|
inherited |
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 434 of file ExecutionEngine.cpp.
References RTT::base::RunnableInterface::getActivity(), and RTT::base::ActivityInterface::start().
|
protectedinherited |
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 338 of file ExecutionEngine.cpp.
References RTT::ExecutionEngine::mmaster, RTT::ExecutionEngine::msg_cond, RTT::ExecutionEngine::msg_lock, RTT::ExecutionEngine::processMessages(), and RTT::os::Condition::wait().
Referenced by RTT::ExecutionEngine::waitForMessages().
|
inherited |
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 281 of file ExecutionEngine.cpp.
References RTT::ExecutionEngine::isSelf(), RTT::ExecutionEngine::mmaster, RTT::ExecutionEngine::waitAndProcessMessages(), RTT::ExecutionEngine::waitForMessages(), and RTT::ExecutionEngine::waitForMessagesInternal().
Referenced by RTT::internal::LocalOperationCallerImpl< FunctionT >::collect_impl(), RTT::scripting::CallFunction::execute(), RTT::ExecutionEngine::removeFunction(), and RTT::ExecutionEngine::waitForMessages().
|
protectedinherited |
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 325 of file ExecutionEngine.cpp.
References RTT::ExecutionEngine::mmaster, RTT::ExecutionEngine::msg_cond, RTT::ExecutionEngine::msg_lock, and RTT::os::Condition::wait().
Referenced by RTT::ExecutionEngine::waitForMessages().
|
protectedvirtualinherited |
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 365 of file ExecutionEngine.cpp.
References RTT::base::RunnableInterface::IOReady, RTT::base::TaskCore::mCycleCounter, RTT::base::TaskCore::mIOCounter, RTT::base::TaskCore::mTimeOutCounter, RTT::base::TaskCore::mTriggerCounter, RTT::ExecutionEngine::processFunctions(), RTT::ExecutionEngine::processHooks(), RTT::ExecutionEngine::processMessages(), RTT::ExecutionEngine::processPortCallbacks(), RTT::ExecutionEngine::taskc, RTT::base::RunnableInterface::TimeOut, and RTT::base::RunnableInterface::Trigger.
|
protectedinherited |
Stores all functions we're executing.
Definition at line 248 of file ExecutionEngine.hpp.
Referenced by RTT::ExecutionEngine::processFunctions(), RTT::ExecutionEngine::removeSelfFunction(), RTT::ExecutionEngine::runFunction(), and RTT::ExecutionEngine::~ExecutionEngine().
|
protectedinherited |
A master ExecutionEngine which should process our messages.
This is used for ExecutionEngines running in a SlaveActivity which forward incoming messages to their master engine.
Definition at line 257 of file ExecutionEngine.hpp.
Referenced by RTT::ExecutionEngine::getThread(), RTT::ExecutionEngine::process(), RTT::ExecutionEngine::setMaster(), RTT::ExecutionEngine::waitAndProcessMessages(), RTT::ExecutionEngine::waitForMessages(), and RTT::ExecutionEngine::waitForMessagesInternal().
|
protectedinherited |
Our Message queue.
Definition at line 238 of file ExecutionEngine.hpp.
Referenced by RTT::ExecutionEngine::hasWork(), RTT::ExecutionEngine::process(), RTT::ExecutionEngine::processMessages(), and RTT::ExecutionEngine::~ExecutionEngine().
|
protectedinherited |
Definition at line 251 of file ExecutionEngine.hpp.
Referenced by RTT::ExecutionEngine::process(), RTT::ExecutionEngine::processFunctions(), RTT::ExecutionEngine::processMessages(), RTT::ExecutionEngine::waitAndProcessMessages(), and RTT::ExecutionEngine::waitForMessagesInternal().
|
protectedinherited |
Definition at line 250 of file ExecutionEngine.hpp.
Referenced by RTT::ExecutionEngine::processMessages(), RTT::ExecutionEngine::waitAndProcessMessages(), and RTT::ExecutionEngine::waitForMessagesInternal().
|
protectedinherited |
The port callback queue.
Definition at line 243 of file ExecutionEngine.hpp.
Referenced by RTT::ExecutionEngine::process(), RTT::ExecutionEngine::processPortCallbacks(), and RTT::ExecutionEngine::~ExecutionEngine().
|
protectedinherited |
The parent or 'owner' of this ExecutionEngine, may be null.
Definition at line 233 of file ExecutionEngine.hpp.
Referenced by RTT::ExecutionEngine::breakLoop(), RTT::ExecutionEngine::getParent(), RTT::ExecutionEngine::process(), RTT::ExecutionEngine::processHooks(), RTT::ExecutionEngine::processPortCallbacks(), RTT::ExecutionEngine::runFunction(), RTT::ExecutionEngine::setExceptionTask(), and RTT::ExecutionEngine::work().