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