YACLib
C++ library for concurrent tasks execution
Loading...
Searching...
No Matches
join.hpp
Go to the documentation of this file.
1#pragma once
2
7
8namespace yaclib {
9
10template <FailPolicy F = FailPolicy::None, typename... Futures,
11 typename = std::enable_if_t<(... && is_combinator_input_v<Futures>)>>
14 return when::When<when::Join, F, void, typename head_t<Futures...>::Core::Trait>(std::move(futures)...);
15}
16
17template <FailPolicy F = FailPolicy::None, typename It, typename = std::enable_if_t<is_input_iterator_v<It>>>
18YACLIB_INLINE auto Join(It begin, std::size_t count) {
19 using T = typename std::iterator_traits<It>::value_type;
20 return when::When<when::Join, F, void, typename T::Core::Trait>(begin, count);
21}
22
23template <FailPolicy F = FailPolicy::None, typename It, typename Sentinel,
24 typename = std::enable_if_t<is_input_range_pair_v<It, Sentinel>>>
26 static_assert(
28 "Use Join(begin, std::distance(begin, end)) instead"); // We don't use std::distance because we want to alert
29 // the user to the fact that it can be expensive.
30
31 return Join<F>(begin, static_cast<std::size_t>(end - begin));
32}
33
34template <FailPolicy F = FailPolicy::None, typename Range, typename = std::enable_if_t<is_input_range_v<Range>>>
36 return Join<F>(std::begin(range), std::end(range));
37}
38
39}; // namespace yaclib
YACLIB_INLINE void CheckSameTrait()
Definition when.hpp:20
auto When(Futures... futures)
Definition when.hpp:318
Contract< V, T > MakeContract()
Creates related future and promise.
Definition contract.hpp:25
typename detail::Head< Args... >::Type head_t
YACLIB_INLINE auto Join(Futures... futures)
Definition join.hpp:12
FailPolicy
This Policy describe how algorithm interpret if Future will be fulfilled by fail (exception or error)