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

split DeviceModule::reportException #135

	-waitting for recovery is now outsourced in function
	DeviceModule::waitForRecovery()

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