diff --git a/src/DeviceModule.cc b/src/DeviceModule.cc index 1d805361ae9fb5d78a98bbaa0d0d5958280cba34..c76830ca207bb7f5a1ae547893ca4517a48144a0 100644 --- a/src/DeviceModule.cc +++ b/src/DeviceModule.cc @@ -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"); } /*********************************************************************************************************************/