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 {
/// virtualise() returns a reference.
mutable VirtualModule virtualisedModule{"INVALID", "", ModuleType::Invalid};
mutable bool virtualisedModule_isValid{false};
std::atomic<bool> testableModeReached{false};
};
} /* namespace ChimeraTK */
......
......@@ -44,6 +44,14 @@ namespace ChimeraTK {
// start the module thread
assert(!moduleThread.joinable());
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 {
void ApplicationModule::mainLoopWrapper() {
Application::registerThread("AM_" + getName());
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
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