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