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();
|
||||
}
|
||||
|
||||
bool nTotalIsZero(void) const
|
||||
{
|
||||
return nTotal == 0;
|
||||
}
|
||||
|
||||
public:
|
||||
const unsigned int nTotal;
|
||||
std::atomic<unsigned int> nSucceeded, nFailed;
|
||||
|
||||
@@ -363,6 +363,12 @@ void SenseApiManager::attachAllSenseDevicesFromSpecsReq(
|
||||
auto request = std::make_shared<AttachAllSenseDevicesFromSpecsReq>(
|
||||
device::DeviceManager::deviceAttachmentSpecs.size(), std::move(cb));
|
||||
|
||||
if (request->loop.nTotalIsZero())
|
||||
{
|
||||
cb(request->loop);
|
||||
return;
|
||||
}
|
||||
|
||||
for (const auto& spec : device::DeviceManager::deviceAttachmentSpecs)
|
||||
{
|
||||
try {
|
||||
@@ -421,6 +427,12 @@ void SenseApiManager::detachAllSenseDevicesReq(
|
||||
auto request = std::make_shared<DetachAllSenseDevicesReq>(
|
||||
device::DeviceManager::deviceAttachmentSpecs.size(), std::move(cb));
|
||||
|
||||
if (request->loop.nTotalIsZero())
|
||||
{
|
||||
cb(request->loop);
|
||||
return;
|
||||
}
|
||||
|
||||
for (const auto& spec : device::DeviceManager::deviceAttachmentSpecs)
|
||||
{
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user