bool ConcurrentTaskSet::tryWait()

in dispenso/task_set.cpp [67:84]


bool ConcurrentTaskSet::tryWait(size_t maxToExecute) {
  while (outstandingTaskCount_.load(std::memory_order_acquire) && maxToExecute--) {
    if (!pool_.tryExecuteNext()) {
      break;
    }
  }

  // Must check completion prior to checking exceptions, otherwise there could be a case where
  // exceptions are checked, then an exception is propagated, and then we return whether all items
  // have been completed, thus dropping the exception.
  if (outstandingTaskCount_.load(std::memory_order_acquire)) {
    return false;
  }

  testAndResetException();

  return true;
}