TaskUtil.h
Go to the documentation of this file.
1
/*
2
* This file is part of ArmarX.
3
*
4
* Copyright (C) 2011-2017, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5
*
6
* ArmarX is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License version 2 as
8
* published by the Free Software Foundation.
9
*
10
* ArmarX is distributed in the hope that it will be useful, but
11
* WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17
*
18
* @package ArmarX
19
* @author Mirko Waechter( mirko.waechter at kit dot edu)
20
* @date 2017
21
* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22
* GNU General Public License
23
*/
24
#pragma once
25
26
#include <functional>
27
28
#include "
PeriodicTask.h
"
29
#include "
RunningTask.h
"
30
31
namespace
armarx
32
{
33
34
/**
35
* Usage:
36
\verbatim
37
SimplePeriodicTask<>::pointer_type task = new SimplePeriodicTask<>([&]
38
{
39
ARMARX_INFO << "Hello world from another thread";
40
}, 100);
41
task->start();
42
\endverbatim
43
*/
44
template
<
class
Functor = std::function<
void
(
void
)>>
45
class
SimplePeriodicTask
:
public
PeriodicTask<SimplePeriodicTask<Functor>>
46
{
47
public
:
48
SimplePeriodicTask
(Functor
f
,
49
int
periodMs,
50
bool
assureMeanInterval =
false
,
51
std::string name =
""
,
52
bool
forceSystemTime =
true
) :
53
PeriodicTask
<
SimplePeriodicTask
<Functor>>(this,
54
&
SimplePeriodicTask
::
runningFn
,
55
periodMs,
56
assureMeanInterval,
57
name,
58
forceSystemTime),
59
f
(
f
)
60
{
61
}
62
63
void
64
runningFn
()
65
{
66
f
();
67
}
68
69
Functor
f
;
70
};
71
template
<
class
... Ts>
72
SimplePeriodicTask
(Ts...) ->
SimplePeriodicTask
<std::function<void(
void
)>>;
73
74
/**
75
* Usage:
76
\verbatim
77
SimpleRunningTask<>::pointer_type task = new SimpleRunningTask<>([&]
78
{
79
ARMARX_INFO << "Hello world from another thread";
80
});
81
task->start();
82
\endverbatim
83
*/
84
template
<
class
Functor = std::function<
void
(
void
)>>
85
class
SimpleRunningTask
:
public
RunningTask
<SimpleRunningTask<Functor>>
86
{
87
public
:
88
SimpleRunningTask
(Functor
f
, std::string name =
""
) :
89
RunningTask
<
SimpleRunningTask
<Functor>>(this, &
SimpleRunningTask
::
runningFn
, name =
""
),
90
f
(
f
)
91
{
92
}
93
94
void
95
runningFn
()
96
{
97
f
();
98
}
99
100
Functor
f
;
101
};
102
template
<
class
... Ts>
103
SimpleRunningTask
(Ts...) ->
SimpleRunningTask
<std::function<void(
void
)>>;
104
105
}
// namespace armarx
armarx::SimpleRunningTask
Usage:
Definition:
TaskUtil.h:85
armarx::SimplePeriodicTask::runningFn
void runningFn()
Definition:
TaskUtil.h:64
armarx::SimpleRunningTask
SimpleRunningTask(Ts...) -> SimpleRunningTask< std::function< void(void)>>
PeriodicTask.h
RunningTask.h
armarx::SimpleRunningTask::SimpleRunningTask
SimpleRunningTask(Functor f, std::string name="")
Definition:
TaskUtil.h:88
armarx::RunningTask
Definition:
ArmarXMultipleObjectsScheduler.h:36
armarx::SimplePeriodicTask::SimplePeriodicTask
SimplePeriodicTask(Functor f, int periodMs, bool assureMeanInterval=false, std::string name="", bool forceSystemTime=true)
Definition:
TaskUtil.h:48
armarx::SimpleRunningTask::f
Functor f
Definition:
TaskUtil.h:100
armarx::SimpleRunningTask::runningFn
void runningFn()
Definition:
TaskUtil.h:95
armarx::SimplePeriodicTask
SimplePeriodicTask(Ts...) -> SimplePeriodicTask< std::function< void(void)>>
armarx::SimplePeriodicTask::f
Functor f
Definition:
TaskUtil.h:69
armarx::PeriodicTask
Definition:
ArmarXManager.h:70
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition:
ArmarXTimeserver.cpp:27
armarx::SimplePeriodicTask
Usage:
Definition:
ApplicationNetworkStats.h:32
ArmarXCore
core
services
tasks
TaskUtil.h
Generated on Sat Apr 12 2025 09:13:28 for armarx_documentation by
1.8.17