YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
PeriodicThread.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef YARP_OS_PERIODICTHREAD_H
8#define YARP_OS_PERIODICTHREAD_H
9
10#include <yarp/os/api.h>
11#include <yarp/os/Time.h>
12
13namespace yarp::os {
14
16{
19};
20
27{
28public:
43 explicit PeriodicThread(double period,
44 ShouldUseSystemClock useSystemClock = ShouldUseSystemClock::No,
45 PeriodicThreadClock clockAccuracy = PeriodicThreadClock::Relative);
46
59 explicit PeriodicThread(double period, PeriodicThreadClock clockAccuracy);
60
61 virtual ~PeriodicThread();
62
67 bool start();
68
74 void step();
75
82 void stop();
83
88 void askToStop();
89
93 bool isRunning() const;
94
98 bool isSuspended() const;
99
105 bool setPeriod(double period);
106
111 double getPeriod() const;
112
117 void suspend();
118
122 void resume();
123
127 void resetStat();
128
132 double getEstimatedPeriod() const;
133
139 void getEstimatedPeriod(double& av, double& std) const;
140
144 unsigned int getIterations() const;
145
150 double getEstimatedUsed() const;
151
157 void getEstimatedUsed(double& av, double& std) const;
158
172 int setPriority(int priority, int policy = -1);
173
178 int getPriority() const;
179
184 int getPolicy() const;
185
186protected:
198 virtual bool threadInit();
199
206 virtual void threadRelease();
207
219 virtual void run() = 0;
220
225 virtual void beforeStart();
226
232 virtual void afterStart(bool success);
233
234#ifndef DOXYGEN_SHOULD_SKIP_THIS
235private:
236 class Private;
237 Private* mPriv;
238#endif // DOXYGEN_SHOULD_SKIP_THIS
239};
240
241} // namespace yarp::os
242
243#endif // YARP_OS_PERIODICTHREAD_H
A mini-server for performing network communication in the background.
An abstraction for a periodic thread.
virtual void run()=0
Loop function.
STL namespace.
An interface to the operating system, including Port based communication.
ShouldUseSystemClock
Definition Time.h:19
#define YARP_os_API
Definition api.h:18