9 #ifndef MRPT_SYSTEM_THREADS_H 10 #define MRPT_SYSTEM_THREADS_H 42 m_thread = std::make_shared<std::thread>();
88 h.
m_thread = std::make_shared<std::thread>(func, std::ref<T>(
param));
94 h.
m_thread = std::make_shared<std::thread>(func);
120 template <
typename CLASS,
typename PARAM>
127 template <
typename CLASS,
typename PARAM>
134 template <
typename CLASS>
137 h.
m_thread = std::make_shared<std::thread>(func,
obj);
165 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...
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.
TProcessPriority
The type for cross-platform process (application) priorities.
GLsizei GLsizei GLuint * obj
TThreadHandle createThreadRef(void(*func)(T &), T ¶m)
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.
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.
void clear()
Mark the handle as invalid.
void BASE_IMPEXP joinThread(TThreadHandle &threadHandle)
Waits until the given thread ends.
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.
std::shared_ptr< std::thread > m_thread
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 BASE_IMPEXP changeCurrentThreadPriority(TThreadPriority priority)
Change the priority of the current thread - for Windows, see also changeCurrentProcessPriority() ...
void BASE_IMPEXP exitThread() MRPT_NO_THROWS
Explicit close of the current (running) thread.