From d7360f57009ad680520082d20ea5af4235e1bfb8 Mon Sep 17 00:00:00 2001 From: Martin Killenberg <martin.killenberg@desy.de> Date: Tue, 14 Apr 2020 14:11:00 +0200 Subject: [PATCH] simplified logic in DeviceModule::waitForRecovery() --- src/DeviceModule.cc | 36 ++++++++++-------------------------- 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/src/DeviceModule.cc b/src/DeviceModule.cc index 1d805361..c76830ca 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"); } /*********************************************************************************************************************/ -- GitLab