YARP
Yet Another Robot Platform
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
13
namespace
yarp
{
14
namespace
os {
15
16
enum class
PeriodicThreadClock
17
{
18
Relative
,
19
Absolute
20
};
21
27
class
YARP_os_API
PeriodicThread
28
{
29
public
:
44
explicit
PeriodicThread
(
double
period,
45
ShouldUseSystemClock
useSystemClock
=
ShouldUseSystemClock::No
,
46
PeriodicThreadClock
clockAccuracy =
PeriodicThreadClock::Relative
);
47
60
explicit
PeriodicThread
(
double
period,
PeriodicThreadClock
clockAccuracy);
61
62
virtual
~
PeriodicThread
();
63
68
bool
start();
69
75
void
step();
76
83
void
stop();
84
89
void
askToStop();
90
94
bool
isRunning()
const
;
95
99
bool
isSuspended()
const
;
100
106
bool
setPeriod(
double
period);
107
112
double
getPeriod()
const
;
113
118
void
suspend();
119
123
void
resume();
124
128
void
resetStat();
129
133
double
getEstimatedPeriod()
const
;
134
140
void
getEstimatedPeriod(
double
& av,
double
& std)
const
;
141
145
unsigned
int
getIterations()
const
;
146
151
double
getEstimatedUsed()
const
;
152
158
void
getEstimatedUsed(
double
& av,
double
& std)
const
;
159
173
int
setPriority(
int
priority,
int
policy = -1);
174
179
int
getPriority()
const
;
180
185
int
getPolicy()
const
;
186
187
protected
:
199
virtual
bool
threadInit();
200
207
virtual
void
threadRelease();
208
220
virtual
void
run
() = 0;
221
226
virtual
void
beforeStart();
227
233
virtual
void
afterStart(
bool
success);
234
235
#ifndef DOXYGEN_SHOULD_SKIP_THIS
236
private
:
237
class
Private
;
238
Private
* mPriv;
239
#endif
// DOXYGEN_SHOULD_SKIP_THIS
240
};
241
242
}
// namespace os
243
}
// namespace yarp
244
245
#endif
// YARP_OS_PERIODICTHREAD_H
yarp::os::PeriodicThread::Private
Definition:
PeriodicThread.cpp:96
yarp::os::PeriodicThread
An abstraction for a periodic thread.
Definition:
PeriodicThread.h:28
yarp::os::PeriodicThread::run
virtual void run()=0
Loop function.
Time.h
yarp::os::Time::useSystemClock
void useSystemClock()
Configure YARP to use system time (this is the default).
Definition:
Time.cpp:144
yarp::os::PeriodicThreadClock
PeriodicThreadClock
Definition:
PeriodicThread.h:17
yarp::os::PeriodicThreadClock::Relative
@ Relative
yarp::os::PeriodicThreadClock::Absolute
@ Absolute
yarp::os::ShouldUseSystemClock
ShouldUseSystemClock
Definition:
Time.h:20
yarp::os::ShouldUseSystemClock::No
@ No
yarp
The main, catch-all namespace for YARP.
Definition:
dirs.h:16
api.h
YARP_os_API
#define YARP_os_API
Definition:
api.h:18
YARP
3.5.1
src
libYARP_os
src
yarp
os
PeriodicThread.h
Generated on Sat Dec 25 2021 02:23:04 for YARP by
1.9.1