Orocos Real-Time Toolkit  2.9.0
ExecutionEngine.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  tag: Peter Soetens Wed Jan 18 14:11:40 CET 2006 ExecutionEngine.hpp
3 
4  ExecutionEngine.hpp - description
5  -------------------
6  begin : Wed January 18 2006
7  copyright : (C) 2006 Peter Soetens
8  email : peter.soetens@mech.kuleuven.be
9 
10  ***************************************************************************
11  * This library is free software; you can redistribute it and/or *
12  * modify it under the terms of the GNU General Public *
13  * License as published by the Free Software Foundation; *
14  * version 2 of the License. *
15  * *
16  * As a special exception, you may use this file as part of a free *
17  * software library without restriction. Specifically, if other files *
18  * instantiate templates or use macros or inline functions from this *
19  * file, or you compile this file and link it with other files to *
20  * produce an executable, this file does not by itself cause the *
21  * resulting executable to be covered by the GNU General Public *
22  * License. This exception does not however invalidate any other *
23  * reasons why the executable file might be covered by the GNU General *
24  * Public License. *
25  * *
26  * This library is distributed in the hope that it will be useful, *
27  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
28  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
29  * Lesser General Public License for more details. *
30  * *
31  * You should have received a copy of the GNU General Public *
32  * License along with this library; if not, write to the Free Software *
33  * Foundation, Inc., 59 Temple Place, *
34  * Suite 330, Boston, MA 02111-1307 USA *
35  * *
36  ***************************************************************************/
37 
38 
39 #ifndef ORO_EXECUTION_ENGINE_HPP
40 #define ORO_EXECUTION_ENGINE_HPP
41 
42 #include "os/Mutex.hpp"
43 #include "os/MutexLock.hpp"
44 #include "os/Condition.hpp"
49 #include "internal/List.hpp"
50 #include <vector>
51 #include <boost/function.hpp>
52 
53 #include "rtt-config.h"
55 
56 namespace RTT
57 {
58 
71  {
72  public:
79  ExecutionEngine( base::TaskCore* owner = 0);
80 
81  ~ExecutionEngine();
82 
87  base::TaskCore* getParent();
88 
93  base::TaskCore* getTaskCore() const { return taskc; }
94 
105  virtual bool process(base::DisposableInterface* c);
106 
114  virtual bool process(base::PortInterface* port);
115 
124  virtual bool runFunction(base::ExecutableInterface* f);
125 
131  virtual bool removeFunction(base::ExecutableInterface* f);
132 
138  virtual bool removeSelfFunction(base::ExecutableInterface* f);
139 
149  void waitForMessages(const boost::function<bool(void)>& pred);
150 
159  bool stopTask(base::TaskCore* task);
160 
161 
165  void setExceptionTask();
166 
173  void setMaster(ExecutionEngine *master);
174 
181  virtual void setActivity( base::ActivityInterface* task );
182 
189  virtual os::ThreadInterface* getThread() const;
190 
198  bool isSelf() const;
199 
200  protected:
214  void waitForMessagesInternal( boost::function<bool(void)> const& pred);
215 
228  void waitAndProcessMessages(boost::function<bool(void)> const& pred);
229 
234 
239 
244 
249 
252 
258 
259  void processMessages();
260  void processPortCallbacks();
261  void processFunctions();
262  void processHooks();
263 
264  virtual bool initialize();
265 
270  virtual void step();
271 
272  virtual void work(RunnableInterface::WorkReason reason);
273 
274  virtual bool breakLoop();
275 
276  virtual void finalize();
277 
278  virtual bool hasWork();
279 
280  };
281 
282 }
283 #endif
We can&#39;t use typedefs since C++ doesn&#39;t allow it for templated classes without specifying all the tem...
The minimal Orocos task.
Definition: TaskCore.hpp:54
ExecutionEngine * mmaster
A master ExecutionEngine which should process our messages.
A class for running a certain piece of code in a thread.
internal::MWSRQueue< base::PortInterface * > * port_queue
The port callback queue.
#define RTT_API
Definition: rtt-config.h:97
An object oriented wrapper around a condition variable.
Definition: Condition.hpp:60
internal::MWSRQueue< base::ExecutableInterface * > * f_queue
Stores all functions we&#39;re executing.
An execution engine serialises (executes one after the other) the execution of all commands...
base::TaskCore * getTaskCore() const
Returns the owner of this execution engine.
A thread which is being run.
internal::MWSRQueue< base::DisposableInterface * > * mqueue
Our Message queue.
Interface to start/stop and query a Activity.
An object that is executable and is freed after execution.
This object represents the default Multi-Writer, Single-Reader queue implementation used by Orocos ob...
Definition: MWSRQueue.hpp:66
base::TaskCore * taskc
The parent or &#39;owner&#39; of this ExecutionEngine, may be null.
Objects that implement this interface are to be executed in the ExecutionEngine.
An object oriented wrapper around a non recursive mutex.
Definition: Mutex.hpp:92
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
Definition: Activity.cpp:52
The base class of every data flow port.