Classes | |
struct | mrpt::system::TThreadHandle |
This structure contains the information needed to interface the threads API on each platform: More... | |
Namespaces | |
namespace | mrpt::system::detail |
Auxiliary classes used internally to MRPT. | |
Enumerations | |
enum | mrpt::system::TProcessPriority { mrpt::system::ppIdle = 0 , mrpt::system::ppNormal , mrpt::system::ppHigh , mrpt::system::ppVeryHigh } |
The type for cross-platform process (application) priorities. More... | |
enum | mrpt::system::TThreadPriority { mrpt::system::tpLowests =-15 , mrpt::system::tpLower = -2 , mrpt::system::tpLow = -1 , mrpt::system::tpNormal = 0 , mrpt::system::tpHigh = 1 , mrpt::system::tpHigher = 2 , mrpt::system::tpHighest = 15 } |
The type for cross-platform thread priorities. More... | |
Functions | |
template<typename T > | |
TThreadHandle | mrpt::system::createThread (void(*func)(T), T param) |
Creates a new thread from a function (or static method) with one generic parameter. | |
template<typename T > | |
TThreadHandle | mrpt::system::createThreadRef (void(*func)(T &), T ¶m) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
TThreadHandle | mrpt::system::createThread (void(*func)(void)) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
template<typename CLASS , typename PARAM > | |
TThreadHandle | mrpt::system::createThreadFromObjectMethod (CLASS *obj, void(CLASS::*func)(PARAM), PARAM param) |
Creates a new thread running a non-static method (so it will have access to "this") from another method of the same class - with one generic parameter. | |
template<typename CLASS , typename PARAM > | |
TThreadHandle | mrpt::system::createThreadFromObjectMethodRef (CLASS *obj, void(CLASS::*func)(PARAM &), PARAM ¶m) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
template<typename CLASS > | |
TThreadHandle | mrpt::system::createThreadFromObjectMethod (CLASS *obj, void(CLASS::*func)(void)) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
void BASE_IMPEXP | mrpt::system::joinThread (const TThreadHandle &threadHandle) |
Waits until the given thread ends. | |
unsigned long BASE_IMPEXP | mrpt::system::getCurrentThreadId () MRPT_NO_THROWS |
Returns the ID of the current thread. | |
TThreadHandle BASE_IMPEXP | mrpt::system::getCurrentThreadHandle () MRPT_NO_THROWS |
Returns a handle to the current thread. | |
void BASE_IMPEXP | mrpt::system::exitThread () MRPT_NO_THROWS |
Explicit close of the current (running) thread. | |
void BASE_IMPEXP | mrpt::system::getCurrentThreadTimes (time_t &creationTime, time_t &exitTime, double &cpuTime) |
Returns the creation and exit times of the current thread and its CPU time consumed. | |
void BASE_IMPEXP | mrpt::system::changeThreadPriority (const TThreadHandle &threadHandle, TThreadPriority priority) |
Change the priority of the given thread - for Windows, see also changeCurrentProcessPriority() | |
void BASE_IMPEXP | mrpt::system::terminateThread (TThreadHandle &threadHandle) MRPT_NO_THROWS |
Terminate a thread, giving it no choice to delete objects, etc (use only as a last resource) | |
void BASE_IMPEXP | mrpt::system::changeCurrentProcessPriority (TProcessPriority priority) |
Change the priority of the given process (it applies to all the threads, plus independent modifiers for each thread). | |
unsigned int BASE_IMPEXP | mrpt::system::getNumberOfProcessors () |
Return the number of processors ("cores"), or 1 if it cannot be determined. | |
void BASE_IMPEXP | mrpt::system::sleep (int time_ms) MRPT_NO_THROWS |
An OS-independent method for sending the current thread to "sleep" for a given period of time. | |
bool BASE_IMPEXP | mrpt::system::launchProcess (const std::string &command) |
Executes the given command (which may contain a program + arguments), and waits until it finishes. | |
The type for cross-platform process (application) priorities.
Enumerator | |
---|---|
ppIdle | |
ppNormal | |
ppHigh | |
ppVeryHigh |
The type for cross-platform thread priorities.
Enumerator | |
---|---|
tpLowests | |
tpLower | |
tpLow | |
tpNormal | |
tpHigh | |
tpHigher | |
tpHighest |
void BASE_IMPEXP mrpt::system::changeCurrentProcessPriority | ( | TProcessPriority | priority | ) |
Change the priority of the given process (it applies to all the threads, plus independent modifiers for each thread).
root
permissions to increase process priority! Internally it calls nice(), so it has no effect if changeThreadPriority() was called and a SCHED_RR is already active. void BASE_IMPEXP mrpt::system::changeThreadPriority | ( | const TThreadHandle & | threadHandle, |
TThreadPriority | priority | ||
) |
Change the priority of the given thread - for Windows, see also changeCurrentProcessPriority()
root
permissions! This sets the Round Robin scheduler with the given priority level. Read sched_setscheduler.
|
inline |
Creates a new thread from a function (or static method) with one generic parameter.
This function creates, and start, a new thread running some code given by a function. The thread function should end by returning as normal.
func | The function with the code to run in the thread. |
param | The parameter to be passed to the new thread function. |
std::exception | If the operation fails |
Definition at line 181 of file threads.h.
References mrpt::system::detail::ThreadCreateFunctor< T >::createThread().
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 189 of file threads.h.
References mrpt::system::detail::ThreadCreateFunctorNoParams::createThread().
|
inline |
Creates a new thread running a non-static method (so it will have access to "this") from another method of the same class - with one generic parameter.
This function creates, and start, a new thread running some code given by a function. The thread function should end by returning as normal. Example of usage:
func | The function with the code to run in the thread. |
param | The parameter to be passed to the new thread function. |
std::exception | If the operation fails |
Definition at line 216 of file threads.h.
References mrpt::system::detail::ThreadCreateObjectFunctor< CLASS, PARAM >::createThread().
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 226 of file threads.h.
References mrpt::system::detail::ThreadCreateObjectFunctorNoParams< CLASS >::createThread().
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 221 of file threads.h.
References mrpt::system::detail::ThreadCreateObjectFunctor< CLASS, PARAM >::createThread().
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 185 of file threads.h.
References mrpt::system::detail::ThreadCreateFunctor< T >::createThread().
void BASE_IMPEXP mrpt::system::exitThread | ( | ) |
Explicit close of the current (running) thread.
Do not use normally, it's better just to return from the running thread function.
TThreadHandle BASE_IMPEXP mrpt::system::getCurrentThreadHandle | ( | ) |
Returns a handle to the current thread.
unsigned long BASE_IMPEXP mrpt::system::getCurrentThreadId | ( | ) |
Returns the ID of the current thread.
void BASE_IMPEXP mrpt::system::getCurrentThreadTimes | ( | time_t & | creationTime, |
time_t & | exitTime, | ||
double & | cpuTime | ||
) |
Returns the creation and exit times of the current thread and its CPU time consumed.
creationTime | The creation time of the thread. |
exitTime | The exit time of the thread, or undefined if it is still running. |
cpuTime | The CPU time consumed by the thread, in seconds. |
std::exception | If the operation fails |
unsigned int BASE_IMPEXP mrpt::system::getNumberOfProcessors | ( | ) |
Return the number of processors ("cores"), or 1 if it cannot be determined.
void BASE_IMPEXP mrpt::system::joinThread | ( | const TThreadHandle & | threadHandle | ) |
Waits until the given thread ends.
bool BASE_IMPEXP mrpt::system::launchProcess | ( | const std::string & | command | ) |
Executes the given command (which may contain a program + arguments), and waits until it finishes.
void BASE_IMPEXP mrpt::system::sleep | ( | int | time_ms | ) |
An OS-independent method for sending the current thread to "sleep" for a given period of time.
time_ms | The sleep period, in miliseconds. |
void BASE_IMPEXP mrpt::system::terminateThread | ( | TThreadHandle & | threadHandle | ) |
Terminate a thread, giving it no choice to delete objects, etc (use only as a last resource)
Page generated by Doxygen 1.9.6 for MRPT 1.4.0 SVN: at Fri Jan 20 02:28:26 UTC 2023 |