mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-14 09:06:47 +00:00
Handle some edge cases
This commit is contained in:
parent
66c01f2cda
commit
d966a0a991
|
@ -153,15 +153,21 @@ void waitMode(const string& waitForState,
|
||||||
StateSubscription stateSubscription(topologyPath, ddsCustomCmd);
|
StateSubscription stateSubscription(topologyPath, ddsCustomCmd);
|
||||||
|
|
||||||
auto condition = [&] {
|
auto condition = [&] {
|
||||||
return all_of(waitForStateMap.cbegin(),
|
return !waitForStateMap.empty() // TODO once DDS provides an API to retrieve actual number of tasks, use it here
|
||||||
|
&& all_of(waitForStateMap.cbegin(),
|
||||||
waitForStateMap.cend(),
|
waitForStateMap.cend(),
|
||||||
[&](WaitForStateMap::value_type i) { return i.second == waitForState; });
|
[&](WaitForStateMap::value_type i) { return i.second == waitForState; });
|
||||||
};
|
};
|
||||||
|
|
||||||
unique_lock<mutex> lock(waitForStateMutex);
|
unique_lock<mutex> lock(waitForStateMutex);
|
||||||
|
|
||||||
|
if (timeout > std::chrono::milliseconds(0)) {
|
||||||
if (!waitForStateCV.wait_for(lock, timeout, condition)) {
|
if (!waitForStateCV.wait_for(lock, timeout, condition)) {
|
||||||
throw runtime_error("timeout");
|
throw runtime_error("timeout");
|
||||||
};
|
}
|
||||||
|
} else {
|
||||||
|
waitForStateCV.wait(lock, condition);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
|
|
Loading…
Reference in New Issue
Block a user