YACLib
C++ library for concurrent tasks execution
Loading...
Searching...
No Matches
await.hpp
Go to the documentation of this file.
1#pragma once
2
8
9namespace yaclib {
10
11template <typename V, typename E>
16
17template <typename Waited, typename = std::enable_if_t<is_waitable_v<Waited>>>
19 return AwaitInline(waited);
20}
21
22template <typename... Waited, typename = std::enable_if_t<(... && is_waitable_v<Waited>)>>
23YACLIB_INLINE auto Await(Waited&... waited) noexcept {
24 return AwaitInline(waited...);
25}
26
28 typename = std::enable_if_t<is_waitable_v<Value>>>
29YACLIB_INLINE auto Await(Iterator begin, std::size_t count) noexcept {
30 return AwaitInline(begin, count);
31}
32
33template <typename Iterator,
34 typename = std::enable_if_t<is_waitable_v<typename std::iterator_traits<Iterator>::value_type>>>
36 return AwaitInline(begin, end);
37}
38
39template <typename V, typename E>
40YACLIB_INLINE auto operator co_await(FutureBase<V, E>&& future) noexcept {
41 YACLIB_ASSERT(future.Valid());
42 return detail::AwaitSingleAwaiter<false, V, E>{std::move(future.GetCore())};
43}
44
45template <typename V, typename E>
46YACLIB_INLINE auto operator co_await(const SharedFutureBase<V, E>& future) noexcept {
47 YACLIB_ASSERT(future.Valid());
49}
50
51template <typename V, typename E>
52YACLIB_INLINE auto operator co_await(Task<V, E>&& task) noexcept {
53 YACLIB_ASSERT(task.Valid());
54 return detail::TransferSingleAwaiter{std::move(task.GetCore())};
55}
56
57} // namespace yaclib
Provides a mechanism to access the result of async operations.
Definition future.hpp:20
Provides a mechanism to schedule the some async operations TODO(MBkkt) add description.
Definition task.hpp:25
#define YACLIB_ASSERT(cond)
Definition log.hpp:85
YACLIB_INLINE auto AwaitInline(Waited &waited) noexcept
YACLIB_INLINE auto Await(Task< V, E > &task) noexcept
Definition await.hpp:12
Contract< V, E > MakeContract()
Creates related future and promise.
Definition contract.hpp:25