Main MRPT website
>
C++ reference for MRPT 1.9.9
rplidar
src
hal
thread.h
Go to the documentation of this file.
1
/* +------------------------------------------------------------------------+
2
| Mobile Robot Programming Toolkit (MRPT) |
3
| http://www.mrpt.org/ |
4
| |
5
| Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6
| See: http://www.mrpt.org/Authors - All rights reserved. |
7
| Released under BSD License. See details in http://www.mrpt.org/License |
8
+------------------------------------------------------------------------+ */
9
/*
10
* Redistribution and use in source and binary forms, with or without
11
* modification, are permitted provided that the following conditions are met:
12
*
13
* 1. Redistributions of source code must retain the above copyright notice,
14
* this list of conditions and the following disclaimer.
15
*
16
* 2. Redistributions in binary form must reproduce the above copyright notice,
17
* this list of conditions and the following disclaimer in the documentation
18
* and/or other materials provided with the distribution.
19
*
20
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
24
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
*
32
*/
33
34
#pragma once
35
36
#include "
rptypes.h
"
37
#define CLASS_THREAD(c, x) rp::hal::Thread::create_member<c, &c::x>(this)
38
39
namespace
rp
40
{
41
namespace
hal
42
{
43
class
Thread
44
{
45
public
:
46
enum
priority_val_t
47
{
48
PRIORITY_REALTIME
= 0,
49
PRIORITY_HIGH
= 1,
50
PRIORITY_NORMAL
= 2,
51
PRIORITY_LOW
= 3,
52
PRIORITY_IDLE
= 4,
53
};
54
55
template
<
class
T, u_result (T::*PROC)(
void
)>
56
static
Thread
create_member
(T* pthis)
57
{
58
return
create
(_thread_thunk<T, PROC>, pthis);
59
}
60
61
template
<
class
T, u_result (T::*PROC)(
void
)>
62
static
_word_size_t THREAD_PROC
_thread_thunk
(
void
*
data
)
63
{
64
return
(
static_cast<
T*
>
(
data
)->*PROC)();
65
}
66
static
Thread
create
(
thread_proc_t
proc,
void
*
data
=
nullptr
);
67
68
public
:
69
~Thread
() {}
70
Thread
() :
_data
(nullptr),
_func
(nullptr),
_handle
(0) {}
71
_word_size_t
getHandle
() {
return
_handle
; }
72
u_result
terminate
();
73
void
*
getData
() {
return
_data
; }
74
u_result
join
(
unsigned
long
timeout = -1);
75
u_result
setPriority
(
priority_val_t
p
);
76
priority_val_t
getPriority
();
77
78
bool
operator==
(
const
Thread
& right)
79
{
80
return
this->
_handle
== right.
_handle
;
81
}
82
83
protected
:
84
Thread
(
thread_proc_t
proc,
void
*
data
)
85
:
_data
(
data
),
_func
(proc),
_handle
(0)
86
{
87
}
88
void
*
_data
;
89
thread_proc_t
_func
;
90
_word_size_t
_handle
;
91
};
92
}
93
}
rp::hal::Thread::join
u_result join(unsigned long timeout=-1)
Definition:
linux/thread.hpp:129
rp::hal::Thread::~Thread
~Thread()
Definition:
thread.h:69
u_result
uint32_t u_result
Definition:
rptypes.h:95
rp::hal::Thread::priority_val_t
priority_val_t
Definition:
thread.h:46
rp::hal::Thread::_data
void * _data
Definition:
thread.h:88
rp::hal::Thread::_handle
_word_size_t _handle
Definition:
thread.h:90
rp::hal::Thread::PRIORITY_IDLE
@ PRIORITY_IDLE
Definition:
thread.h:52
rp::hal::Thread::Thread
Thread(thread_proc_t proc, void *data)
Definition:
thread.h:84
rp::hal::Thread
Definition:
thread.h:43
rp::hal::Thread::PRIORITY_NORMAL
@ PRIORITY_NORMAL
Definition:
thread.h:50
p
GLfloat GLfloat p
Definition:
glext.h:6305
thread_proc_t
_word_size_t(THREAD_PROC * thread_proc_t)(void *)
Definition:
rptypes.h:111
rp::hal::Thread::create
static Thread create(thread_proc_t proc, void *data=nullptr)
Definition:
linux/thread.hpp:41
data
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition:
glext.h:3547
rp::hal::Thread::_func
thread_proc_t _func
Definition:
thread.h:89
rptypes.h
rp::hal::Thread::Thread
Thread()
Definition:
thread.h:70
rp::hal::Thread::getData
void * getData()
Definition:
thread.h:73
rp::hal::Thread::getPriority
priority_val_t getPriority()
Definition:
linux/thread.hpp:103
rp::hal::Thread::terminate
u_result terminate()
Definition:
linux/thread.hpp:53
rp::hal::Thread::PRIORITY_LOW
@ PRIORITY_LOW
Definition:
thread.h:51
rp::hal::Thread::PRIORITY_HIGH
@ PRIORITY_HIGH
Definition:
thread.h:49
rp::hal::Thread::create_member
static Thread create_member(T *pthis)
Definition:
thread.h:56
rp::hal::Thread::getHandle
_word_size_t getHandle()
Definition:
thread.h:71
rp::hal::Thread::PRIORITY_REALTIME
@ PRIORITY_REALTIME
Definition:
thread.h:48
rp
Definition:
rplidar_driver.h:40
rp::hal::Thread::operator==
bool operator==(const Thread &right)
Definition:
thread.h:78
rp::hal::Thread::_thread_thunk
static _word_size_t THREAD_PROC _thread_thunk(void *data)
Definition:
thread.h:62
rp::hal::Thread::setPriority
u_result setPriority(priority_val_t p)
Definition:
linux/thread.hpp:60
Page generated by
Doxygen 1.8.17
for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST