mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-13 16:46: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);
|
||||
|
||||
auto condition = [&] {
|
||||
return all_of(waitForStateMap.cbegin(),
|
||||
waitForStateMap.cend(),
|
||||
[&](WaitForStateMap::value_type i) { return i.second == waitForState; });
|
||||
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::value_type i) { return i.second == waitForState; });
|
||||
};
|
||||
|
||||
unique_lock<mutex> lock(waitForStateMutex);
|
||||
if (!waitForStateCV.wait_for(lock, timeout, condition)) {
|
||||
throw runtime_error("timeout");
|
||||
};
|
||||
|
||||
if (timeout > std::chrono::milliseconds(0)) {
|
||||
if (!waitForStateCV.wait_for(lock, timeout, condition)) {
|
||||
throw runtime_error("timeout");
|
||||
}
|
||||
} else {
|
||||
waitForStateCV.wait(lock, condition);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
|
|
Loading…
Reference in New Issue
Block a user