Skip to content
Snippets Groups Projects
Commit 47aca077 authored by Martin Killenberg's avatar Martin Killenberg
Browse files

TestableMode: ApplicationModule guarantees that the main loop thread had the...

TestableMode: ApplicationModule guarantees that the main loop thread had the testableModeLock at least once. Solves #66
parent b803d321
No related branches found
No related tags found
No related merge requests found
...@@ -64,6 +64,7 @@ namespace ChimeraTK { ...@@ -64,6 +64,7 @@ namespace ChimeraTK {
/// virtualise() returns a reference. /// virtualise() returns a reference.
mutable VirtualModule virtualisedModule{"INVALID", "", ModuleType::Invalid}; mutable VirtualModule virtualisedModule{"INVALID", "", ModuleType::Invalid};
mutable bool virtualisedModule_isValid{false}; mutable bool virtualisedModule_isValid{false};
std::atomic<bool> testableModeReached{false};
}; };
} /* namespace ChimeraTK */ } /* namespace ChimeraTK */
......
...@@ -44,6 +44,14 @@ namespace ChimeraTK { ...@@ -44,6 +44,14 @@ namespace ChimeraTK {
// start the module thread // start the module thread
assert(!moduleThread.joinable()); assert(!moduleThread.joinable());
moduleThread = boost::thread(&ApplicationModule::mainLoopWrapper, this); moduleThread = boost::thread(&ApplicationModule::mainLoopWrapper, this);
//Wait until the thread has launched and acquired and released the testable mode lock at least once.
if(Application::getInstance().isTestableModeEnabled()) {
while(!testableModeReached) {
Application::getInstance().testableModeUnlock("releaseForReachTestableMode");
usleep(100);
Application::getInstance().testableModeLock("acquireForReachTestableMode");
}
}
} }
/*********************************************************************************************************************/ /*********************************************************************************************************************/
...@@ -74,6 +82,8 @@ namespace ChimeraTK { ...@@ -74,6 +82,8 @@ namespace ChimeraTK {
void ApplicationModule::mainLoopWrapper() { void ApplicationModule::mainLoopWrapper() {
Application::registerThread("AM_" + getName()); Application::registerThread("AM_" + getName());
Application::testableModeLock("start"); Application::testableModeLock("start");
// We are holding the testable mode lock, so we are sure the mechanism will work now.
testableModeReached = true;
// enter the main loop // enter the main loop
mainLoop(); mainLoop();
Application::testableModeUnlock("terminate"); 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