Go to the documentation of this file.
9 #ifndef MRPT_SYSTEM_THREADS_H
10 #define MRPT_SYSTEM_THREADS_H
27 #ifdef MRPT_OS_WINDOWS
43 # if defined(HAVE_OPENTHREAD) // defined(_MSC_VER) && (_MSC_VER>=1400)
46 unsigned long idThread;
49 #if defined(MRPT_OS_LINUX) || defined(MRPT_OS_APPLE)
53 unsigned long idThread;
64 bool isClear()
const {
return idThread==0; }
100 auxStruct->
func(auxStruct->
obj);
132 template <
class CLASS,
class PARAM>
143 (auxStruct->
obj->*f)(auxStruct->
p);
152 template <
class CLASS>
162 (auxStruct->
obj->*f)();
215 template <
typename CLASS,
typename PARAM>
220 template <
typename CLASS,
typename PARAM>
225 template <
typename CLASS>
259 time_t &creationTime,
ThreadCreateObjectFunctor(CLASS *o, objectfunctor_t f, PARAM param)
void BASE_IMPEXP terminateThread(TThreadHandle &threadHandle) MRPT_NO_THROWS
Terminate a thread, giving it no choice to delete objects, etc (use only as a last resource)
TThreadHandle 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 meth...
static TThreadHandle createThread(CLASS *o, objectfunctor_t f)
static void createThreadAux(void *obj)
ThreadCreateObjectFunctorNoParams(CLASS *o, objectfunctor_t f)
TThreadHandle createThreadRef(void(*func)(T &), T ¶m)
This is an overloaded member function, provided for convenience. It differs from the above function o...
TThreadHandle createThread(void(*func)(T), T param)
Creates a new thread from a function (or static method) with one generic parameter.
void BASE_IMPEXP changeThreadPriority(const TThreadHandle &threadHandle, TThreadPriority priority)
Change the priority of the given thread - for Windows, see also changeCurrentProcessPriority()
ThreadCreateFunctorNoParams(void(*f)(void))
#define MRPT_NO_THROWS
Used after member declarations.
TThreadHandle BASE_IMPEXP getCurrentThreadHandle() MRPT_NO_THROWS
Returns a handle to the current thread.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
bool isClear() const
Returns true if the handle is uninitialized.
TThreadPriority
The type for cross-platform thread priorities.
TThreadHandle BASE_IMPEXP createThreadImpl(void(*func)(void *), void *param)
unsigned long BASE_IMPEXP getCurrentThreadId() MRPT_NO_THROWS
Returns the ID of the current thread.
void BASE_IMPEXP exitThread() MRPT_NO_THROWS
Explicit close of the current (running) thread.
void BASE_IMPEXP joinThread(const TThreadHandle &threadHandle)
Waits until the given thread ends.
unsigned int BASE_IMPEXP getNumberOfProcessors()
Return the number of processors ("cores"), or 1 if it cannot be determined.
static void createThreadAux(void *p)
static TThreadHandle createThread(CLASS *o, objectfunctor_t f, PARAM param)
void(CLASS::* objectfunctor_t)(PARAM)
bool BASE_IMPEXP launchProcess(const std::string &command)
Executes the given command (which may contain a program + arguments), and waits until it finishes.
static TThreadHandle createThread(void(*f)(T), T param)
void BASE_IMPEXP getCurrentThreadTimes(time_t &creationTime, time_t &exitTime, double &cpuTime)
Returns the creation and exit times of the current thread and its CPU time consumed.
TProcessPriority
The type for cross-platform process (application) priorities.
void BASE_IMPEXP changeCurrentProcessPriority(TProcessPriority priority)
Change the priority of the given process (it applies to all the threads, plus independent modifiers f...
This structure contains the information needed to interface the threads API on each platform:
ThreadCreateFunctor(void(*f)(T), T o)
void BASE_IMPEXP sleep(int time_ms) MRPT_NO_THROWS
An OS-independent method for sending the current thread to "sleep" for a given period of time.
static void createThreadAux(void *f)
static TThreadHandle createThread(void(*f)(void))
static void createThreadAux(void *p)
void(CLASS::* objectfunctor_t)(void)
TThreadHandle createThreadFromObjectMethodRef(CLASS *obj, void(CLASS::*func)(PARAM &), PARAM ¶m)
This is an overloaded member function, provided for convenience. It differs from the above function o...
static TThreadHandle createThread(void(*f)(void *), void *param)
Page generated by Doxygen 1.8.16 for MRPT 1.4.0 SVN: at Mon Oct 14 22:32:58 UTC 2019 | | |