Line |
Branch |
Exec |
Source |
1 |
|
|
/** |
2 |
|
|
* @file demo_thread.cpp |
3 |
|
|
* @author Vincent Berenz |
4 |
|
|
* license License BSD-3-Clause |
5 |
|
|
* @copyright Copyright (c) 2019, New York University and Max Planck |
6 |
|
|
* Gesellschaft. |
7 |
|
|
* @date 2020-01-02 |
8 |
|
|
* |
9 |
|
|
* @brief Mininal thread example |
10 |
|
|
*/ |
11 |
|
|
|
12 |
|
|
#include "real_time_tools/thread.hpp" |
13 |
|
|
#include "real_time_tools/timer.hpp" |
14 |
|
|
|
15 |
|
✗ |
THREAD_FUNCTION_RETURN_TYPE thread_function(void*) |
16 |
|
|
{ |
17 |
|
✗ |
int i = 0; |
18 |
|
|
while (true) |
19 |
|
|
{ |
20 |
|
✗ |
i += 1; |
21 |
|
✗ |
if (i % 1000 == 0) |
22 |
|
|
{ |
23 |
|
✗ |
rt_printf("iteration %d\n", i); |
24 |
|
|
} |
25 |
|
✗ |
real_time_tools::Timer::sleep_microseconds(1000); |
26 |
|
|
} |
27 |
|
|
return THREAD_FUNCTION_RETURN_VALUE; |
28 |
|
|
} |
29 |
|
|
|
30 |
|
✗ |
int main() |
31 |
|
|
{ |
32 |
|
✗ |
real_time_tools::RealTimeThread thread; |
33 |
|
✗ |
thread.block_memory(); |
34 |
|
✗ |
thread.create_realtime_thread(thread_function); |
35 |
|
✗ |
thread.join(); |
36 |
|
|
} |
37 |
|
|
|