9 #ifndef MRPT_SYSTEM_THREADS_H
10 #define MRPT_SYSTEM_THREADS_H
27 #ifdef MRPT_OS_WINDOWS
43 # if defined(HAVE_OPENTHREAD)
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,
static TThreadHandle createThread(void(*f)(void *), void *param)
ThreadCreateFunctor(void(*f)(T), T o)
static TThreadHandle createThread(void(*f)(T), T param)
static void createThreadAux(void *obj)
static TThreadHandle createThread(void(*f)(void))
static void createThreadAux(void *f)
ThreadCreateFunctorNoParams(void(*f)(void))
ThreadCreateObjectFunctor(CLASS *o, objectfunctor_t f, PARAM param)
void(CLASS::* objectfunctor_t)(PARAM)
static TThreadHandle createThread(CLASS *o, objectfunctor_t f, PARAM param)
static void createThreadAux(void *p)
void(CLASS::* objectfunctor_t)(void)
static TThreadHandle createThread(CLASS *o, objectfunctor_t f)
ThreadCreateObjectFunctorNoParams(CLASS *o, objectfunctor_t f)
static void createThreadAux(void *p)
GLsizei GLsizei GLuint * obj
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
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...
TThreadHandle BASE_IMPEXP getCurrentThreadHandle() MRPT_NO_THROWS
Returns a handle to the current thread.
unsigned int BASE_IMPEXP getNumberOfProcessors()
Return the number of processors ("cores"), or 1 if it cannot be determined.
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 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...
TThreadHandle createThread(void(*func)(T), T param)
Creates a new thread from a function (or static method) with one generic parameter.
TThreadPriority
The type for cross-platform thread priorities.
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.
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.
TThreadHandle createThreadRef(void(*func)(T &), T ¶m)
This is an overloaded member function, provided for convenience. It differs from the above function o...
TProcessPriority
The type for cross-platform process (application) priorities.
void BASE_IMPEXP changeThreadPriority(const TThreadHandle &threadHandle, TThreadPriority priority)
Change the priority of the given thread - for Windows, see also changeCurrentProcessPriority()
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.
void BASE_IMPEXP changeCurrentProcessPriority(TProcessPriority priority)
Change the priority of the given process (it applies to all the threads, plus independent modifiers f...
bool BASE_IMPEXP launchProcess(const std::string &command)
Executes the given command (which may contain a program + arguments), and waits until it finishes.
unsigned long BASE_IMPEXP getCurrentThreadId() MRPT_NO_THROWS
Returns the ID of the current thread.
#define MRPT_NO_THROWS
C++11 noexcept: Used after member declarations.
TThreadHandle BASE_IMPEXP createThreadImpl(void(*func)(void *), void *param)
void clear()
Clear the contents of this container.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
This structure contains the information needed to interface the threads API on each platform:
bool isClear() const
Returns true if the handle is uninitialized.