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::os
{
14
15
enum class
PeriodicThreadClock
16
{
17
Relative
,
18
Absolute
19
};
20
26
class
YARP_os_API
PeriodicThread
27
{
28
public
:
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
186
protected
:
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
235
private
:
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
yarp::os::PeriodicThread::Private
Definition:
PeriodicThread.cpp:96
yarp::os::PeriodicThread
An abstraction for a periodic thread.
Definition:
PeriodicThread.h:27
yarp::os::PeriodicThread::run
virtual void run()=0
Loop function.
Time.h
std
STL namespace.
yarp::os::Time::useSystemClock
void useSystemClock()
Configure YARP to use system time (this is the default).
Definition:
Time.cpp:144
yarp::os
An interface to the operating system, including Port based communication.
Definition:
AbstractCarrier.h:13
yarp::os::PeriodicThreadClock
PeriodicThreadClock
Definition:
PeriodicThread.h:16
yarp::os::PeriodicThreadClock::Relative
@ Relative
yarp::os::PeriodicThreadClock::Absolute
@ Absolute
yarp::os::ShouldUseSystemClock
ShouldUseSystemClock
Definition:
Time.h:19
yarp::os::ShouldUseSystemClock::No
@ No
api.h
YARP_os_API
#define YARP_os_API
Definition:
api.h:18
YARP
3.7.2+72-20221008.2+gitbb7fa68a9
src
libYARP_os
src
yarp
os
PeriodicThread.h
Generated on Thu Oct 27 2022 02:58:50 for YARP by
1.9.4