Classes | |
struct | mrpt::system::TThreadHandle |
A MRPT thread handle. More... | |
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. More... | |
template<typename T > | |
TThreadHandle | mrpt::system::createThreadRef (void(*func)(T &), T ¶m) |
TThreadHandle | mrpt::system::createThread (void(*func)(void)) |
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. More... | |
template<typename CLASS , typename PARAM > | |
TThreadHandle | mrpt::system::createThreadFromObjectMethodRef (CLASS *obj, void(CLASS::*func)(PARAM &), PARAM ¶m) |
template<typename CLASS > | |
TThreadHandle | mrpt::system::createThreadFromObjectMethod (CLASS *obj, void(CLASS::*func)(void)) |
void BASE_IMPEXP | mrpt::system::joinThread (TThreadHandle &threadHandle) |
Waits until the given thread ends. More... | |
unsigned long BASE_IMPEXP | mrpt::system::getCurrentThreadId () MRPT_NO_THROWS |
Returns the ID of the current thread. More... | |
void BASE_IMPEXP | mrpt::system::exitThread () MRPT_NO_THROWS |
Explicit close of the current (running) thread. More... | |
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. More... | |
void BASE_IMPEXP | mrpt::system::changeCurrentThreadPriority (TThreadPriority priority) |
Change the priority of the current thread - for Windows, see also changeCurrentProcessPriority() More... | |
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) More... | |
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). More... | |
unsigned int BASE_IMPEXP | mrpt::system::getNumberOfProcessors () |
Return the number of processors ("cores"), or 1 if it cannot be determined. More... | |
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. More... | |
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. More... | |
The type for cross-platform process (application) priorities.
Enumerator | |
---|---|
ppIdle | |
ppNormal | |
ppHigh | |
ppVeryHigh |
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 () was called and a SCHED_RR is already active. Definition at line 144 of file threads.cpp.
References mrpt::system::ppHigh, mrpt::system::ppIdle, mrpt::system::ppNormal, mrpt::system::ppVeryHigh, and THROW_EXCEPTION.
void BASE_IMPEXP mrpt::system::changeCurrentThreadPriority | ( | TThreadPriority | priority | ) |
Change the priority of the current thread - for Windows, see also changeCurrentProcessPriority()
root
permissions! This sets the Round Robin scheduler with the given priority level. Read sched_setscheduler.
Definition at line 94 of file threads.cpp.
References mrpt::system::tpHigh, mrpt::system::tpHigher, mrpt::system::tpHighest, mrpt::system::tpLow, mrpt::system::tpLower, mrpt::system::tpLowests, and mrpt::system::tpNormal.
|
inline |
Creates a new thread from a function (or static method) with one generic parameter.
This function creates, and starts 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 80 of file threads.h.
References mrpt::system::TThreadHandle::m_thread.
Referenced by mrpt::gui::WxSubsystem::createOneInstanceMainThread(), mrpt::detectors::CFaceDetection::init(), mrpt::hwdrivers::CImpinjRFID::initialize(), my_CriticalSections_Multi(), and my_CSemaphore().
|
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 92 of file threads.h.
References mrpt::system::TThreadHandle::m_thread.
|
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 starts 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 121 of file threads.h.
References mrpt::system::TThreadHandle::m_thread.
Referenced by mrpt::system::CFileSystemWatcher::CFileSystemWatcher(), mrpt::hmtslam::CHMTSLAM::CHMTSLAM(), mrpt::hwdrivers::CNTRIPClient::CNTRIPClient(), mrpt::hwdrivers::CIbeoLuxETH::initialize(), mrpt::hwdrivers::CCameraSensor::initialize(), mrpt::pbmap::PbMapLocaliser::PbMapLocaliser(), mrpt::pbmap::PbMapMaker::PbMapMaker(), mrpt::hwdrivers::CRovio::retrieve_video(), and mrpt::graphslam::optimizers::CLevMarqGSO< GRAPH_T >::updateState().
|
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 135 of file threads.h.
References mrpt::system::TThreadHandle::m_thread.
|
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 128 of file threads.h.
References mrpt::system::TThreadHandle::m_thread.
|
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 86 of file threads.h.
References mrpt::system::TThreadHandle::m_thread.
Referenced by mrpt::utils::net::DNS_resolve_async().
void 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.
Definition at line 367 of file threads.cpp.
Referenced by mrpt::hwdrivers::CImpinjRFID::startDriver().
unsigned long mrpt::system::getCurrentThreadId | ( | ) |
Returns the ID of the current thread.
Definition at line 83 of file threads.cpp.
Referenced by mrpt::synch::CCriticalSection::enter(), mrpt::system::getCurrentThreadTimes(), mrpt::synch::CCriticalSection::leave(), mrpt::graphslam::optimizers::CLevMarqGSO< GRAPH_T >::optimizeGraph(), sem_thread_example(), mrpt::hmtslam::CHMTSLAM::thread_3D_viewer(), mrpt::hmtslam::CHMTSLAM::thread_LSLAM(), and mrpt::hmtslam::CHMTSLAM::thread_TBI().
void 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 |
Definition at line 180 of file threads.cpp.
References FALSE, mrpt::format(), mrpt::system::getCurrentThreadId(), info, MRPT_END, MRPT_START, MRPT_UNUSED_PARAM, THROW_EXCEPTION, and mrpt::system::tokenize().
Referenced by mrpt::hmtslam::CHMTSLAM::thread_3D_viewer(), mrpt::hmtslam::CHMTSLAM::thread_LSLAM(), and mrpt::hmtslam::CHMTSLAM::thread_TBI().
unsigned int mrpt::system::getNumberOfProcessors | ( | ) |
Return the number of processors ("cores"), or 1 if it cannot be determined.
Definition at line 327 of file threads.cpp.
void mrpt::system::joinThread | ( | TThreadHandle & | threadHandle | ) |
Waits until the given thread ends.
Definition at line 74 of file threads.cpp.
References mrpt::system::TThreadHandle::m_thread.
Referenced by mrpt::hwdrivers::CCameraSensor::close(), mrpt::utils::net::DNS_resolve_async(), mrpt::hwdrivers::CNationalInstrumentsDAQ::initialize(), my_CSemaphore(), mrpt::pbmap::PbMapLocaliser::stop_pbMapLocaliser(), mrpt::pbmap::PbMapMaker::stop_pbMapMaker(), mrpt::hwdrivers::CRovio::stop_video(), mrpt::graphslam::optimizers::CLevMarqGSO< GRAPH_T >::updateState(), mrpt::detectors::CFaceDetection::~CFaceDetection(), mrpt::hmtslam::CHMTSLAM::~CHMTSLAM(), mrpt::hwdrivers::CIbeoLuxETH::~CIbeoLuxETH(), and mrpt::hwdrivers::CNTRIPClient::~CNTRIPClient().
bool mrpt::system::launchProcess | ( | const std::string & | command | ) |
Executes the given command (which may contain a program + arguments), and waits until it finishes.
Definition at line 295 of file threads.cpp.
Referenced by mrpt::vision::CFeatureExtraction::extractFeaturesSIFT(), and mrpt::vision::CFeatureExtraction::internal_computeSiftDescriptors().
void 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. |
Definition at line 57 of file threads.cpp.
References mrpt::utils::CTicTac::Tac(), and mrpt::utils::CTicTac::Tic().
Referenced by mrpt::slam::CGridMapAligner::AlignPDF_correlation(), mrpt::hwdrivers::CEnoseModular::checkConnectionAndConnect(), mrpt::hwdrivers::CBoardENoses::checkConnectionAndConnect(), mrpt::hwdrivers::CBoardSonars::checkConnectionAndConnect(), mrpt::hwdrivers::CServoeNeck::checkConnectionAndConnect(), mrpt::hwdrivers::CSickLaserUSB::checkControllerIsConnected(), mrpt::hwdrivers::CImpinjRFID::connect(), mrpt::gui::CBaseGUIWindow::createWxWindow(), mrpt::gui::CBaseGUIWindow::destroyWxWindow(), mrpt::detectors::CCascadeClassifierDetection::detectObjects_Impl(), mrpt::hwdrivers::CGillAnemometer::doProcess(), mrpt::hwdrivers::CRaePID::doProcess(), mrpt::hwdrivers::CIMUXSens_MT4::doProcess(), mrpt::hwdrivers::CIMUXSens::doProcess(), mrpt::hwdrivers::CSkeletonTracker::doProcess(), mrpt::hwdrivers::CNTRIPEmitter::doProcess(), mrpt::hwdrivers::CIMUIntersense::doProcess(), mrpt::hwdrivers::CGyroKVHDSP3000::doProcess(), mrpt::graphslam::deciders::CICPCriteriaERD< GRAPH_T >::dumpVisibilityErrorMsg(), mrpt::graphslam::deciders::CLoopCloserERD< GRAPH_T >::dumpVisibilityErrorMsg(), mrpt::graphslam::CGraphSlamEngine< GRAPH_T >::dumpVisibilityErrorMsg(), mrpt::hwdrivers::CVelodyneScanner::getNextObservation(), mrpt::hwdrivers::CImageGrabber_OpenCV::getObservation(), mrpt::gui::CBaseGUIWindow::getPushedKey(), mrpt::hwdrivers::CNationalInstrumentsDAQ::grabbing_thread(), mrpt::utils::net::http_request(), mrpt::hwdrivers::CIMUIntersense::initialize(), mrpt::hwdrivers::CVelodyneScanner::internal_read_PCAP_packet(), mrpt::hwdrivers::CGPSInterface::JAVAD_sendMessage(), launchTestWithTimeout(), mrpt::hwdrivers::CGPSInterface::legacy_topcon_setup_commands(), mrpt::hwdrivers::CSickLaserSerial::LMS_setupSerialComms(), xsens::msleep(), my_CriticalSections_Multi(), my_CSemaphore(), mrpt::hwdrivers::CGPSInterface::OnConnectionEstablished(), mrpt::hwdrivers::CGPSInterface::OnConnectionShutdown(), mrpt::hwdrivers::COpenNI2Generic::open(), mrpt::graphslam::CGraphSlamEngine< GRAPH_T >::pauseExec(), mrpt::hwdrivers::prepareVideoSourceFromUserSelection(), mrpt::hwdrivers::CNTRIPClient::private_ntrip_thread(), mrpt::hwdrivers::CBoardSonars::programI2CAddress(), mrpt::hwdrivers::CServoeNeck::queryFirmwareVersion(), mrpt::hwdrivers::CSerialPort::Read(), mrpt::hwdrivers::CSerialPort::ReadString(), mrpt::hwdrivers::CTuMicos::reset(), mrpt::hwdrivers::CRovio::retrieve_video(), mrpt::pbmap::PbMapLocaliser::run(), mrpt::pbmap::PbMapMaker::run(), mrpt::hwdrivers::CPtuDPerception::scan(), sem_thread_example(), mrpt::hwdrivers::CSickLaserSerial::SendCommandToSICK(), mrpt::hwdrivers::CServoeNeck::setRegisterValue(), mrpt::hwdrivers::CServoeNeck::setRegisterValueAndSpeed(), mrpt::hwdrivers::CCANBusReader::setupSerialComms(), mrpt::hwdrivers::CImpinjRFID::startDriver(), mrpt::hwdrivers::CNationalInstrumentsDAQ::stop(), mrpt::pbmap::PbMapLocaliser::stop_pbMapLocaliser(), mrpt::pbmap::PbMapMaker::stop_pbMapMaker(), mrpt::hmtslam::CHMTSLAM::thread_3D_viewer(), thread_example(), mrpt::hmtslam::CHMTSLAM::thread_LSLAM(), mrpt::hwdrivers::CCameraSensor::thread_save_images(), mrpt::hmtslam::CHMTSLAM::thread_TBI(), mrpt::hwdrivers::CRovio::thread_video(), mrpt::hwdrivers::CLMS100Eth::turnOn(), mrpt::hwdrivers::CGPSInterface::unsetJAVAD_AIM_mode(), mrpt::pbmap::PbMapMaker::viz_cb(), mrpt::hwdrivers::CCANBusReader::waitContinuousSampleFrame(), mrpt::hwdrivers::CSickLaserSerial::waitContinuousSampleFrame(), mrpt::gui::CBaseGUIWindow::waitForKey(), mrpt::gui::WxSubsystem::waitWxShutdownsIfNoWindows(), CGraphSlamHandler< GRAPH_T >::~CGraphSlamHandler(), and mrpt::hwdrivers::CIbeoLuxETH::~CIbeoLuxETH().
void mrpt::system::terminateThread | ( | TThreadHandle & | threadHandle | ) |
Terminate a thread, giving it no choice to delete objects, etc (use only as a last resource)
Definition at line 379 of file threads.cpp.
Referenced by mrpt::system::CFileSystemWatcher::~CFileSystemWatcher().
Page generated by Doxygen 1.8.14 for MRPT 1.5.7 Git: 5902e14cc Wed Apr 24 15:04:01 2019 +0200 at lun oct 28 01:39:17 CET 2019 |