FileDescriptorActivity.hpp
Go to the documentation of this file.
1 /***************************************************************************
2  tag: Peter Soetens Thu Oct 22 11:59:08 CEST 2009 FileDescriptorActivity.hpp
3 
4  FileDescriptorActivity.hpp - description
5  -------------------
6  begin : Thu October 22 2009
7  copyright : (C) 2009 Peter Soetens
8  email : peter@thesourcworks.com
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 FILEDESCRIPTOR_ACTIVITY_HPP
40 #define FILEDESCRIPTOR_ACTIVITY_HPP
41 
43 #include "../Activity.hpp"
44 #include <set>
45 
46 namespace RTT { namespace extras {
47 
105  public Activity
106  {
107  std::set<int> m_watched_fds;
108  bool m_running;
109  int m_interrupt_pipe[2];
112 
114  fd_set m_fd_set;
115  fd_set m_fd_work;
118 
119  static const char CMD_ANY_COMMAND = 0;
122  bool m_trigger;
124 
128  void triggerUpdateSets();
129 
130  public:
140  FileDescriptorActivity(int priority, base::RunnableInterface* _r = 0, const std::string& name ="FileDescriptorActivity" );
141 
152  FileDescriptorActivity(int scheduler, int priority, base::RunnableInterface* _r = 0, const std::string& name ="FileDescriptorActivity" );
153 
165  FileDescriptorActivity(int scheduler, int priority, Seconds period, base::RunnableInterface* _r = 0, const std::string& name ="FileDescriptorActivity" );
166 
179  FileDescriptorActivity(int scheduler, int priority, Seconds period, unsigned cpu_affinity,
180  base::RunnableInterface* _r = 0, const std::string& name ="FileDescriptorActivity" );
181 
182  virtual ~FileDescriptorActivity();
183 
184  bool isRunning() const;
185 
187  virtual Seconds getPeriod() const;
188 
190  virtual bool setPeriod(Seconds period);
191 
198  void watch(int fd);
199 
206  void unwatch(int fd);
207 
209  void clearAllWatches();
210 
215  bool isWatched(int fd) const;
216 
225  bool isUpdated(int fd) const;
226 
234  bool hasTimeout() const;
235 
243  bool hasError() const;
244 
252  void setTimeout(int timeout);
253 
261  void setTimeout_us(int timeout_us);
262 
268  int getTimeout() const;
269 
275  int getTimeout_us() const;
276 
277  virtual bool start();
278  virtual void loop();
279  virtual bool breakLoop();
280  virtual bool stop();
281 
285  virtual void step();
286 
290  virtual void work(base::RunnableInterface::WorkReason reason);
291 
295  virtual bool trigger();
296 
300  virtual bool timeout();
301  };
302 }}
303 
304 #endif
double Seconds
Definition: os/Time.hpp:53
A class for running a certain piece of code in a thread.
An Activity executes a RunnableInterface object in a (periodic) thread.
Definition: Activity.hpp:70
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:53
Seconds m_period
timeout in microseconds
RTT::os::Mutex m_lock
intended period
static bool trigger(TaskContext *tc)


rtt
Author(s): RTT Developers
autogenerated on Tue Jun 25 2019 19:33:24