AsyncLoop: Add test for zero-iteration loops
This mnemonically ensures that we'll remember to check for these kinds of async loops.
This commit is contained in:
@@ -33,6 +33,11 @@ public:
|
|||||||
return isComplete();
|
return isComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool nTotalIsZero(void) const
|
||||||
|
{
|
||||||
|
return nTotal == 0;
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
const unsigned int nTotal;
|
const unsigned int nTotal;
|
||||||
std::atomic<unsigned int> nSucceeded, nFailed;
|
std::atomic<unsigned int> nSucceeded, nFailed;
|
||||||
|
|||||||
@@ -363,6 +363,12 @@ void SenseApiManager::attachAllSenseDevicesFromSpecsReq(
|
|||||||
auto request = std::make_shared<AttachAllSenseDevicesFromSpecsReq>(
|
auto request = std::make_shared<AttachAllSenseDevicesFromSpecsReq>(
|
||||||
device::DeviceManager::deviceAttachmentSpecs.size(), std::move(cb));
|
device::DeviceManager::deviceAttachmentSpecs.size(), std::move(cb));
|
||||||
|
|
||||||
|
if (request->loop.nTotalIsZero())
|
||||||
|
{
|
||||||
|
cb(request->loop);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (const auto& spec : device::DeviceManager::deviceAttachmentSpecs)
|
for (const auto& spec : device::DeviceManager::deviceAttachmentSpecs)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
@@ -421,6 +427,12 @@ void SenseApiManager::detachAllSenseDevicesReq(
|
|||||||
auto request = std::make_shared<DetachAllSenseDevicesReq>(
|
auto request = std::make_shared<DetachAllSenseDevicesReq>(
|
||||||
device::DeviceManager::deviceAttachmentSpecs.size(), std::move(cb));
|
device::DeviceManager::deviceAttachmentSpecs.size(), std::move(cb));
|
||||||
|
|
||||||
|
if (request->loop.nTotalIsZero())
|
||||||
|
{
|
||||||
|
cb(request->loop);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (const auto& spec : device::DeviceManager::deviceAttachmentSpecs)
|
for (const auto& spec : device::DeviceManager::deviceAttachmentSpecs)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user