Skip to content
Snippets Groups Projects
Commit e9de85b1 authored by Martin Christoph Hierholzer's avatar Martin Christoph Hierholzer
Browse files

make sure all threads are properly named

parent 385c4060
No related branches found
Tags 02.04.00
No related merge requests found
......@@ -79,7 +79,11 @@ namespace ChimeraTK {
*
* Note: Enabling the testable mode will have a singificant impact on the performance, since it will prevent
* any module threads to run at the same time! */
void enableTestableMode() { testableMode = true; testableModeLock("enableTestableMode"); }
void enableTestableMode() {
testableMode = true;
testableModeLock("enableTestableMode");
testableModeThreadName() = "TEST THREAD";
}
/** Resume the application until all application threads are stuck in a blocking read operation. Works only when
* the testable mode was enabled. */
......@@ -101,6 +105,7 @@ namespace ChimeraTK {
*
* This function should generally not be used in user code. */
static void testableModeLock(const std::string& name) {
if(!getInstance().testableMode) return;
if(getInstance().enableDebugTestableMode) {
std::cout << "Application::testableModeLock(): Thread " << testableModeThreadName()
<< " tries to obtain lock for " << name << std::endl;
......@@ -119,6 +124,7 @@ namespace ChimeraTK {
*
* This function should generally not be used in user code. */
static void testableModeUnlock(const std::string& name) {
if(!getInstance().testableMode) return;
if(getInstance().enableDebugTestableMode) {
std::cout << "Application::testableModeUnlock(): Thread " << testableModeThreadName()
<< " releases lock for " << name << std::endl;
......@@ -130,6 +136,7 @@ namespace ChimeraTK {
*
* This function should generally not be used in user code. */
static bool testableModeTestLock() {
if(!getInstance().testableMode) return false;
return getTestableModeLockObject().owns_lock();
}
......
......@@ -47,7 +47,8 @@ namespace ChimeraTK {
/** Synchronise feeder and the consumers. This function is executed in the separate thread. */
void run() {
Application::getInstance().testableModeThreadName() = "Threaded "+FanOut<UserType>::impl->getName();
Application::getInstance().testableModeThreadName() = "ThreadedFanOut "+FanOut<UserType>::impl->getName();
Application::testableModeLock("start");
while(true) {
// receive data
boost::this_thread::interruption_point();
......
......@@ -59,6 +59,7 @@ namespace ChimeraTK {
/** Synchronise feeder and the consumers. This function is executed in the separate thread. */
void run() {
Application::getInstance().testableModeThreadName() = "TriggerFanOut "+externalTrigger->getName();
Application::testableModeLock("start");
while(true) {
// wait for external trigger
boost::this_thread::interruption_point();
......
......@@ -37,8 +37,10 @@ namespace ChimeraTK {
void ApplicationModule::mainLoopWrapper() {
Application::getInstance().testableModeThreadName() = "ApplicatioModule "+getName();
Application::testableModeLock("start");
// enter the main loop
mainLoop();
Application::testableModeUnlock("terminate");
}
/*********************************************************************************************************************/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment