YACLib
C++ library for concurrent tasks execution
Loading...
Searching...
No Matches
when_impl.hpp
Go to the documentation of this file.
1#pragma once
2
5
6#include <cstddef>
7#include <utility>
8
9namespace yaclib::detail {
10
11// Combinator should be pointer for case when count == 0
12template <typename Combinator, typename It>
13void WhenImpl(Combinator* combinator, It it, std::size_t count) noexcept {
14 for (std::size_t i = 0; i != count; ++i) {
15 YACLIB_ASSERT(it->Valid());
16 combinator->AddInput(*it->GetCore().Release());
17 ++it;
18 }
19}
20
21template <typename Combinator, typename E, typename... V>
23 YACLIB_ASSERT(... && fs.Valid());
24 // TODO(MBkkt) Make Impl for BaseCore's instead of futures
25 (..., combinator.AddInput(*fs.GetCore().Release()));
26}
27
28template <bool SymmetricTransfer>
30 if constexpr (SymmetricTransfer) {
31 return callback->template SetResult<true>();
32 } else {
34 return Noop<false>();
35 }
36}
37
38} // namespace yaclib::detail
Provides a mechanism to access the result of async operations.
Definition future.hpp:20
#define YACLIB_ASSERT(cond)
Definition log.hpp:85
auto WhenSetResult(BaseCore *callback)
Definition when_impl.hpp:29
void WhenImpl(Combinator *combinator, It it, std::size_t count) noexcept
Definition when_impl.hpp:13
YACLIB_INLINE void Loop(InlineCore *prev, InlineCore *curr) noexcept
Definition base_core.hpp:69
Contract< V, E > MakeContract()
Creates related future and promise.
Definition contract.hpp:25