SenseApiMgr: Use new loop convenience methods
This commit is contained in:
@@ -327,14 +327,15 @@ void SenseApiManager::attachAllSenseDevicesFromSpecs(void)
|
|||||||
{
|
{
|
||||||
if (!success)
|
if (!success)
|
||||||
{
|
{
|
||||||
++loop.nFailed;
|
|
||||||
std::cerr << __func__ << ": Failed to attach device: "
|
std::cerr << __func__ << ": Failed to attach device: "
|
||||||
<< spec->deviceIdentifier << "\n";
|
<< spec->deviceIdentifier << "\n";
|
||||||
} else {
|
|
||||||
++loop.nSucceeded;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!loop.isComplete()) { return; }
|
if (!loop.incrementSuccessOrFailureAndTestForCompletionDueTo(
|
||||||
|
success))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
std::cout << __func__ << ": " << loop.nSucceeded.load()
|
std::cout << __func__ << ": " << loop.nSucceeded.load()
|
||||||
<< " devices attached, "
|
<< " devices attached, "
|
||||||
@@ -344,8 +345,7 @@ void SenseApiManager::attachAllSenseDevicesFromSpecs(void)
|
|||||||
});
|
});
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
std::cerr << __func__ << ": Exception: " << e.what() << "\n";
|
std::cerr << __func__ << ": Exception: " << e.what() << "\n";
|
||||||
++loop.nFailed;
|
if (loop.incrementSuccessOrFailureAndTestForCompletionDueTo(false))
|
||||||
if (loop.isComplete())
|
|
||||||
{ bridge.setAsyncOperationComplete(); }
|
{ bridge.setAsyncOperationComplete(); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -358,7 +358,7 @@ void SenseApiManager::attachAllSenseDevicesFromSpecs(void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (loop.nTotal.load() != loop.nSucceeded.load() + loop.nFailed.load())
|
if (!loop.isComplete())
|
||||||
{
|
{
|
||||||
throw std::runtime_error(
|
throw std::runtime_error(
|
||||||
std::string(__func__) + ": Failed to get through all devices");
|
std::string(__func__) + ": Failed to get through all devices");
|
||||||
@@ -384,14 +384,15 @@ void SenseApiManager::detachAllSenseDevicesReq(void)
|
|||||||
{
|
{
|
||||||
if (!success)
|
if (!success)
|
||||||
{
|
{
|
||||||
++loop.nFailed;
|
|
||||||
std::cerr << __func__ << ": Failed to detach device: "
|
std::cerr << __func__ << ": Failed to detach device: "
|
||||||
<< spec->deviceIdentifier << "\n";
|
<< spec->deviceIdentifier << "\n";
|
||||||
} else {
|
|
||||||
++loop.nSucceeded;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!loop.isComplete()) { return; }
|
if (!loop.incrementSuccessOrFailureAndTestForCompletionDueTo(
|
||||||
|
success))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
std::cout << __func__ << ": " << loop.nSucceeded.load()
|
std::cout << __func__ << ": " << loop.nSucceeded.load()
|
||||||
<< " devices detached, "
|
<< " devices detached, "
|
||||||
@@ -401,8 +402,7 @@ void SenseApiManager::detachAllSenseDevicesReq(void)
|
|||||||
});
|
});
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
std::cerr << __func__ << ": Exception: " << e.what() << "\n";
|
std::cerr << __func__ << ": Exception: " << e.what() << "\n";
|
||||||
++loop.nFailed;
|
if (loop.incrementSuccessOrFailureAndTestForCompletionDueTo(false))
|
||||||
if (loop.isComplete())
|
|
||||||
{ bridge.setAsyncOperationComplete(); }
|
{ bridge.setAsyncOperationComplete(); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -415,7 +415,7 @@ void SenseApiManager::detachAllSenseDevicesReq(void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (loop.nTotal.load() != loop.nSucceeded.load() + loop.nFailed.load())
|
if (!loop.isComplete())
|
||||||
{
|
{
|
||||||
throw std::runtime_error(
|
throw std::runtime_error(
|
||||||
std::string(__func__) + ": Failed to get through all devices");
|
std::string(__func__) + ": Failed to get through all devices");
|
||||||
|
|||||||
Reference in New Issue
Block a user