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,
TThreadPriority
The type for cross-platform thread priorities.
unsigned long BASE_IMPEXP getCurrentThreadId() MRPT_NO_THROWS
Returns the ID of the current thread.
void BASE_IMPEXP changeCurrentProcessPriority(TProcessPriority priority)
Change the priority of the given process (it applies to all the threads, plus independent modifiers f...
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))
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.
#define MRPT_NO_THROWS
C++11 noexcept: Used after member declarations.
static TThreadHandle createThread(CLASS *o, objectfunctor_t f, PARAM param)
TProcessPriority
The type for cross-platform process (application) priorities.
GLsizei GLsizei GLuint * obj
TThreadHandle createThreadRef(void(*func)(T &), T ¶m)
void(CLASS::* objectfunctor_t)(PARAM)
static TThreadHandle createThread(void(*f)(void *), void *param)
void clear()
Clear the contents of this container.
TThreadHandle createThread(void(*func)(T), T param)
Creates a new thread from a function (or static method) with one generic parameter.
bool BASE_IMPEXP launchProcess(const std::string &command)
Executes the given command (which may contain a program + arguments), and waits until it finishes...
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.
static TThreadHandle createThread(void(*f)(T), T param)
ThreadCreateObjectFunctor(CLASS *o, objectfunctor_t f, PARAM param)
static void createThreadAux(void *f)
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...
bool isClear() const
Returns true if the handle is uninitialized.
static void createThreadAux(void *obj)
ThreadCreateObjectFunctorNoParams(CLASS *o, objectfunctor_t f)
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 createThreadFromObjectMethodRef(CLASS *obj, void(CLASS::*func)(PARAM &), PARAM ¶m)
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
ThreadCreateFunctor(void(*f)(T), T o)
This structure contains the information needed to interface the threads API on each platform: ...
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) ...
void(CLASS::* objectfunctor_t)(void)
static void createThreadAux(void *p)
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
TThreadHandle BASE_IMPEXP createThreadImpl(void(*func)(void *), void *param)
static void createThreadAux(void *p)
static TThreadHandle createThread(void(*f)(void))
void BASE_IMPEXP exitThread() MRPT_NO_THROWS
Explicit close of the current (running) thread.
static TThreadHandle createThread(CLASS *o, objectfunctor_t f)
void BASE_IMPEXP joinThread(const TThreadHandle &threadHandle)
Waits until the given thread ends.