Skip to content
Snippets Groups Projects
Commit 4ae0e719 authored by Jan H. K. Timm's avatar Jan H. K. Timm
Browse files

Merge branch 'iss135'

parents 8164f3fe 79d35390
No related branches found
No related tags found
No related merge requests found
...@@ -116,6 +116,7 @@ namespace ChimeraTK { ...@@ -116,6 +116,7 @@ namespace ChimeraTK {
* handling is done internally by ApplicationCore. * handling is done internally by ApplicationCore.
* This functions is blocking until the Device reports isFunctional() again.*/ * This functions is blocking until the Device reports isFunctional() again.*/
void reportException(std::string errMsg); void reportException(std::string errMsg);
void waitForRecovery();
void prepare() override; void prepare() override;
......
...@@ -108,7 +108,9 @@ namespace ChimeraTK { ...@@ -108,7 +108,9 @@ namespace ChimeraTK {
lastValidity = DataValidity::faulty; lastValidity = DataValidity::faulty;
boost::fusion::for_each(fanOutMap.table, SendDataToConsumers(version, lastValidity)); boost::fusion::for_each(fanOutMap.table, SendDataToConsumers(version, lastValidity));
} }
// _deviceModule.reportException(e.what());
_deviceModule.reportException(e.what()); _deviceModule.reportException(e.what());
_deviceModule.waitForRecovery();
goto retry; goto retry;
} }
// send the version number to the consumers // send the version number to the consumers
......
...@@ -220,6 +220,7 @@ namespace ChimeraTK { ...@@ -220,6 +220,7 @@ namespace ChimeraTK {
return virtualisedModuleFromCatalog; return virtualisedModuleFromCatalog;
} }
/*********************************************************************************************************************/ /*********************************************************************************************************************/
void DeviceModule::reportException(std::string errMsg) { void DeviceModule::reportException(std::string errMsg) {
...@@ -248,16 +249,36 @@ namespace ChimeraTK { ...@@ -248,16 +249,36 @@ namespace ChimeraTK {
errorLock.unlock(); 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 catch(...) {
owner->testableModeUnlock("waitForDeviceOK"); //catch any to notify the waiting thread(s) (exception handling thread), then re-throw
errorLock.lock(); errorIsReportedCondVar.notify_all();
while(deviceHasError) { throw;
errorIsResolvedCondVar.wait(errorLock); }
boost::this_thread::interruption_point(); }
/*********************************************************************************************************************/
void DeviceModule::waitForRecovery() {
try {
if(owner->isTestableModeEnabled()) {
assert(owner->testableModeTestLock());
} }
// see waitForException
std::unique_lock<std::mutex> errorLock(errorMutex);
errorLock.unlock(); errorLock.unlock();
owner->testableModeLock("continueAfterException");
//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(...) {
//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
......
...@@ -76,7 +76,9 @@ namespace ChimeraTK { ...@@ -76,7 +76,9 @@ namespace ChimeraTK {
} }
catch(ChimeraTK::runtime_error& e) { catch(ChimeraTK::runtime_error& e) {
setOwnerValidityFunction(/*hasExceptionNow = */ true); setOwnerValidityFunction(/*hasExceptionNow = */ true);
// deviceModule.reportException(e.what());
deviceModule.reportException(e.what()); deviceModule.reportException(e.what());
deviceModule.waitForRecovery();
} }
} }
} }
......
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