aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/threading/future/wait/wait-inl.h
blob: 9d056ff77719e5e0b43704fec1b3977178796998 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#pragma once

#if !defined(INCLUDE_FUTURE_INL_H)
#error "you should never include wait-inl.h directly"
#endif // INCLUDE_FUTURE_INL_H 

namespace NThreading {
    namespace NImpl { 
        template <typename TContainer>
        TVector<TFuture<void>> ToVoidFutures(const TContainer& futures) {
            TVector<TFuture<void>> voidFutures;
            voidFutures.reserve(futures.size());

            for (const auto& future: futures) {
                voidFutures.push_back(future.IgnoreResult());
            }

            return voidFutures;
        }
    } 

    template <typename TContainer>
    [[nodiscard]] NImpl::EnableGenericWait<TContainer> WaitAll(const TContainer& futures) {
        return WaitAll(NImpl::ToVoidFutures(futures));
    }

    template <typename TContainer> 
    [[nodiscard]] NImpl::EnableGenericWait<TContainer> WaitExceptionOrAll(const TContainer& futures) {
        return WaitExceptionOrAll(NImpl::ToVoidFutures(futures));
    }

    template <typename TContainer> 
    [[nodiscard]] NImpl::EnableGenericWait<TContainer> WaitAny(const TContainer& futures) {
        return WaitAny(NImpl::ToVoidFutures(futures));
    }
}