YARP
Yet Another Robot Platform
PeriodicThread.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2019 Istituto Italiano di Tecnologia (IIT)
3  * Copyright (C) 2006-2010 RobotCub Consortium
4  * All rights reserved.
5  *
6  * This software may be modified and distributed under the terms of the
7  * BSD-3-Clause license. See the accompanying LICENSE file for details.
8  */
9 
10 #ifndef YARP_OS_PERIODICTHREAD_H
11 #define YARP_OS_PERIODICTHREAD_H
12 
13 #include <yarp/os/api.h>
14 #include <yarp/os/Time.h>
15 
16 namespace yarp {
17 namespace os {
18 
25 {
26 public:
38  explicit PeriodicThread(double period,
40 
41  virtual ~PeriodicThread();
42 
47  bool start();
48 
54  void step();
55 
62  void stop();
63 
68  void askToStop();
69 
73  bool isRunning() const;
74 
78  bool isSuspended() const;
79 
85  bool setPeriod(double period);
86 
91  double getPeriod() const;
92 
97  void suspend();
98 
102  void resume();
103 
107  void resetStat();
108 
112  double getEstimatedPeriod() const;
113 
119  void getEstimatedPeriod(double& av, double& std) const;
120 
124  unsigned int getIterations() const;
125 
130  double getEstimatedUsed() const;
131 
137  void getEstimatedUsed(double& av, double& std) const;
138 
152  int setPriority(int priority, int policy = -1);
153 
158  int getPriority() const;
159 
164  int getPolicy() const;
165 
166 protected:
178  virtual bool threadInit();
179 
186  virtual void threadRelease();
187 
199  virtual void run() = 0;
200 
205  virtual void beforeStart();
206 
212  virtual void afterStart(bool success);
213 
214 #ifndef DOXYGEN_SHOULD_SKIP_THIS
215 private:
216  class Private;
217  Private* mPriv;
218 #endif // DOXYGEN_SHOULD_SKIP_THIS
219 };
220 
221 } // namespace os
222 } // namespace yarp
223 
224 #endif // YARP_OS_PERIODICTHREAD_H
STL namespace.
#define YARP_OS_API
Definition: api.h:19
void useSystemClock()
Configure YARP to use system time (this is the default).
Definition: Time.cpp:144
ShouldUseSystemClock
Definition: Time.h:22
The main, catch-all namespace for YARP.
Definition: numeric.h:47
An abstraction for a periodic thread.