#include <signal.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <cstdlib>
#include <fstream>
#include <sstream>
#include <thread>
#include <mutex>
#include <unordered_map>
#include <mx/mxlib.hpp>
#include <mx/app/application.hpp>
#include <mx/sys/environment.hpp>
#include <mx/sys/timeUtils.hpp>
#include <mx/ioutils/fileUtils.hpp>
#include "../common/environment.hpp"
#include "../common/paths.hpp"
#include "../common/defaults.hpp"
#include "../common/config.hpp"
#include "../logger/logFileRaw.hpp"
#include "../logger/logManager.hpp"
#include "../sys/thSetuid.hpp"
#include "stateCodes.hpp"
#include "indiDriver.hpp"
#include "indiMacros.hpp"
#include "indiUtils.hpp"
Go to the source code of this file.
|
#define | XWCAPP_THREAD_START(thrdSt, thrdInit, thrdId, thrdProp, thrdPrio, thrdCpuset, thrdName, thrdStart) |
| Error handling wrapper for the threadStart function of the XWCApp. More...
|
|
#define | XWCAPP_THREAD_CHECK(thrdSt, thrdName) |
| Error handling wrapper for checking on thread status with tryjoin. More...
|
|
#define | XWCAPP_THREAD_STOP(thrdSt) |
| Error handlng wrapper for stopping a thread. More...
|
|
◆ XWCAPP_THREAD_CHECK
#define XWCAPP_THREAD_CHECK |
( |
|
thrdSt, |
|
|
|
thrdName |
|
) |
| |
Value: try \
{ \
if( pthread_tryjoin_np( thrdSt.native_handle(), 0 ) == 0 ) \
{ \
log<software_error>( { __FILE__, __LINE__, #thrdName " thread has exited" } ); \
return -1; \
} \
} \
catch( ... ) \
{ \
log<software_error>( { __FILE__, __LINE__, #thrdName " thread has exited" } ); \
return -1; \
}
Error handling wrapper for checking on thread status with tryjoin.
This should be placed in appLogic for each thread managed by an MagAOXApp. If the thread has exited or otherwise causes an error the app will exit.
- Parameters
-
thrdSt | [in] (std::thread) The thread object to start executing |
thrdName | [in] (const std::string &) The name of the thread (just for logging) |
Definition at line 3541 of file MagAOXApp.hpp.
◆ XWCAPP_THREAD_START
#define XWCAPP_THREAD_START |
( |
|
thrdSt, |
|
|
|
thrdInit, |
|
|
|
thrdId, |
|
|
|
thrdProp, |
|
|
|
thrdPrio, |
|
|
|
thrdCpuset, |
|
|
|
thrdName, |
|
|
|
thrdStart |
|
) |
| |
Value: if( threadStart( thrdSt, thrdInit, thrdId, thrdProp, thrdPrio, thrdCpuset, thrdName, this, thrdStart ) < 0 ) \
{ \
log<software_error>( { __FILE__, __LINE__, "error from threadStart for " #thrdName } ); \
return -1; \
}
Error handling wrapper for the threadStart function of the XWCApp.
This should be placed in appLogic for each thread managed by an MagAOXApp. On error, this will cause the app to shutdown.
- See also
- MagAOXApp::threadStart
- Parameters
-
thrdSt | [out] (std::thread) The thread object to start executing |
thrdInit | [in/out] (bool) The thread initilization synchronizer. |
thrdId | [in/out] (pid_t) The thread pid to be filled in by thrdStart immediately upon call |
thrdProp | [in/out](pcf::IndiProperty) The INDI property to publish the thread details |
thrdPrio | [in] (int) The r/t priority to set for this thread |
thrdCpuset | [in] (const std::string &) the cpuset to place this thread on. Ignored if "". |
thrdName | [in] (const std::string &) The name of the thread (just for logging) |
thrdStart | [in] (function) The thread starting function, a static function taking a this pointer as argument. |
Definition at line 3527 of file MagAOXApp.hpp.
◆ XWCAPP_THREAD_STOP
#define XWCAPP_THREAD_STOP |
( |
|
thrdSt | ) |
|
Value: if( thrdSt.joinable() ) \
{ \
pthread_kill( thrdSt.native_handle(), SIGUSR1 ); \
try \
{ \
thrdSt.join(); \
} \
catch( ... ) \
{ \
} \
}
Error handlng wrapper for stopping a thread.
This should be placed in appShutdown for each thread managed by an MagAOXApp.
- Parameters
-
thrdSt | [in] (std::thread) The thread object to start executing |
Definition at line 3561 of file MagAOXApp.hpp.