YACLib
C++ library for concurrent tasks execution
Loading...
Searching...
No Matches
await_on.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <
yaclib/async/future.hpp
>
4
#include <
yaclib/coro/coro.hpp
>
5
#include <
yaclib/coro/detail/await_on_awaiter.hpp
>
6
#include <
yaclib/util/type_traits.hpp
>
7
8
namespace
yaclib
{
9
10
template
<
typename
... V,
typename
...
E
>
11
YACLIB_INLINE
auto
AwaitOn
(
IExecutor
&
e
,
FutureBase<V, E>
&...
fs
)
noexcept
{
12
return
detail::AwaitOnAwaiter
<
sizeof
...(fs) == 1>{
e
,
UpCast<detail::BaseCore>
(*
fs
.GetCore())...};
13
}
14
15
/**
16
* TODO(mkornaukhov03) Add doxygen docs
17
*/
18
template
<
typename
Iterator>
19
YACLIB_INLINE
auto
AwaitOn
(
IExecutor
&
e
,
Iterator
begin
, std::size_t count)
noexcept
20
-> std::enable_if_t<!is_future_base_v<Iterator>,
detail::AwaitOnAwaiter<false>
> {
21
return
detail::AwaitOnAwaiter<false>
{
e
,
begin
, count};
22
}
23
24
/**
25
* TODO(mkornaukhov03) Add doxygen docs
26
*/
27
template
<
typename
BeginIt,
typename
EndIt>
28
YACLIB_INLINE
auto
AwaitOn
(
IExecutor
&
e
,
BeginIt
begin
,
EndIt
end
)
noexcept
29
-> std::enable_if_t<!is_future_base_v<BeginIt>,
detail::AwaitOnAwaiter<false>
> {
30
// We don't use std::distance because we want to alert the user to the fact that it can be expensive.
31
// Maybe the user has the size of the range, otherwise it is suggested to call Await(begin, distance(begin, end))
32
return
AwaitOn
(
e
,
begin
,
static_cast<
std::size_t
>
(
end
-
begin
));
33
}
34
35
}
// namespace yaclib
future.hpp
await_on_awaiter.hpp
yaclib::FutureBase
Provides a mechanism to access the result of async operations.
Definition
future.hpp:20
yaclib::IExecutor
Definition
executor.hpp:8
coro.hpp
yaclib
Definition
base_core.hpp:18
yaclib::AwaitOn
YACLIB_INLINE auto AwaitOn(IExecutor &e, FutureBase< V, E > &... fs) noexcept
Definition
await_on.hpp:11
yaclib::MakeContract
Contract< V, E > MakeContract()
Creates related future and promise.
Definition
contract.hpp:25
yaclib::detail::AwaitOnAwaiter
Definition
await_on_awaiter.hpp:48
type_traits.hpp
include
yaclib
coro
await_on.hpp
Generated by
1.9.8