wait-inl.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #pragma once
  2. #if !defined(INCLUDE_FUTURE_INL_H)
  3. #error "you should never include wait-inl.h directly"
  4. #endif // INCLUDE_FUTURE_INL_H
  5. namespace NThreading {
  6. namespace NImpl {
  7. template <typename TContainer>
  8. TVector<TFuture<void>> ToVoidFutures(const TContainer& futures) {
  9. TVector<TFuture<void>> voidFutures;
  10. voidFutures.reserve(futures.size());
  11. for (const auto& future: futures) {
  12. voidFutures.push_back(future.IgnoreResult());
  13. }
  14. return voidFutures;
  15. }
  16. }
  17. template <typename TContainer>
  18. [[nodiscard]] NImpl::EnableGenericWait<TContainer> WaitAll(const TContainer& futures) {
  19. return WaitAll(NImpl::ToVoidFutures(futures));
  20. }
  21. template <typename TContainer>
  22. [[nodiscard]] NImpl::EnableGenericWait<TContainer> WaitExceptionOrAll(const TContainer& futures) {
  23. return WaitExceptionOrAll(NImpl::ToVoidFutures(futures));
  24. }
  25. template <typename TContainer>
  26. [[nodiscard]] NImpl::EnableGenericWait<TContainer> WaitAny(const TContainer& futures) {
  27. return WaitAny(NImpl::ToVoidFutures(futures));
  28. }
  29. }