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

simplified logic in DeviceModule::waitForRecovery()

parent 451c6cfd
No related branches found
No related tags found
No related merge requests found
......@@ -220,7 +220,6 @@ namespace ChimeraTK {
return virtualisedModuleFromCatalog;
}
/*********************************************************************************************************************/
void DeviceModule::reportException(std::string errMsg) {
......@@ -248,7 +247,6 @@ namespace ChimeraTK {
else {
errorLock.unlock();
}
}
catch(...) {
//catch any to notify the waiting thread(s) (exception handling thread), then re-throw
......@@ -260,31 +258,17 @@ namespace ChimeraTK {
/*********************************************************************************************************************/
void DeviceModule::waitForRecovery() {
try {
if(owner->isTestableModeEnabled()) {
assert(owner->testableModeTestLock());
}
// see waitForException
//Wait until the error condition has been cleared by the exception handling thread.
//We must not hold the testable mode mutex while doing so, otherwise the other thread will never run to fulfill the condition
owner->testableModeUnlock("waitForDeviceOK");
{
std::unique_lock<std::mutex> errorLock(errorMutex);
errorLock.unlock();
//Wait until the error condition has been cleared by the exception handling thread.
//We must not hold the testable mode mutex while doing so, otherwise the other thread will never run to fulfill the condition
owner->testableModeUnlock("waitForDeviceOK");
errorLock.lock();
while(deviceHasError) {
errorIsResolvedCondVar.wait(errorLock);
boost::this_thread::interruption_point();
}
errorLock.unlock();
owner->testableModeLock("continueAfterException");
}
catch(...) {
//catch any to notify the waiting thread(s) (exception handling thread), then re-throw
errorIsReportedCondVar.notify_all();
throw;
}
while(deviceHasError) {
errorIsResolvedCondVar.wait(errorLock);
boost::this_thread::interruption_point();
}
} // end scope of error lock. We must not hold it when trying to get the testable mode lock.
owner->testableModeLock("continueAfterException");
}
/*********************************************************************************************************************/
......
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