18 #include <experimental/coroutine> 24 #include <glog/logging.h> 42 std::experimental::coroutine_handle<promise_type>::from_promise(
56 std::experimental::coroutine_handle<promise_type> coro)
noexcept {
58 auto& promise = coro.promise();
59 promise.executor_->add(promise.continuation_);
68 LOG(
FATAL) <<
"ViaCoroutine threw an unhandled exception";
74 std::experimental::coroutine_handle<> continuation)
noexcept {
101 std::experimental::coroutine_handle<> continuation)
noexcept {
103 coro_.promise().setContinuation(continuation);
121 return ViaCoroutine{std::experimental::coroutine_handle<promise_type>{}};
128 std::experimental::coroutine_handle<promise_type> coro)
noexcept 131 std::experimental::coroutine_handle<promise_type>
coro_;
136 template <
typename Awaiter>
140 folly::coro::is_awaiter_v<Awaiter>,
141 "Awaiter type does not implement the Awaiter interface.");
143 template <
typename Awaitable>
149 template <
typename Awaitable>
156 noexcept(
std::declval<Awaiter&>().await_ready())) {
157 return awaiter_.await_ready();
162 noexcept(std::declval<Awaiter&>().await_suspend(continuation))) {
163 return awaiter_.await_suspend(
164 viaCoroutine_.getWrappedCoroutine(continuation));
168 noexcept(
std::declval<Awaiter&>().await_resume())) {
169 viaCoroutine_.destroy();
170 return awaiter_.await_resume();
177 template <
typename Awaitable>
183 awaitable)
noexcept(
std::is_nothrow_move_constructible<Awaitable>::
185 :
executor_(executor), awaitable_(static_cast<Awaitable&&>(awaitable)) {}
187 template <
typename Awaitable2>
191 template <
typename Awaitable2>
195 template <
typename Awaitable2>
196 friend auto operator co_await(
200 template <
typename Awaitable2>
201 friend auto operator co_await(
210 template <
typename Awaitable>
214 awaitable.executor_,
static_cast<Awaitable&&
>(awaitable.awaitable_)};
217 template <
typename Awaitable>
221 awaitable.executor_, awaitable.awaitable_};
224 template <
typename Awaitable>
229 static_cast<const Awaitable&&
>(awaitable.awaitable_)};
232 template <
typename Awaitable>
236 awaitable.executor_, awaitable.awaitable_};
246 template <
typename Awaitable>
250 folly::coro::is_awaitable_v<Awaitable>,
251 "co_viaIfAsync() argument 2 is not awaitable.");
253 static_cast<Awaitable&&
>(awaitable)};
std::experimental::coroutine_handle continuation_
bool await_ready() noexcept(noexcept(std::declval< Awaiter & >().await_ready()))
folly::Executor * executor_
auto await_suspend(std::experimental::coroutine_handle<> continuation) noexcept(noexcept(std::declval< Awaiter & >().await_suspend(continuation)))
auto co_viaIfAsync(folly::Executor *executor, Awaitable &&awaitable) -> ViaIfAsyncAwaitable< Awaitable >
—— Concurrent Priority Queue Implementation ——
void setContinuation(std::experimental::coroutine_handle<> continuation) noexcept
ViaCoroutine(ViaCoroutine &&other) noexcept
requires E e noexcept(noexcept(s.error(std::move(e))))
ViaCoroutine get_return_object() noexcept
PUSHMI_INLINE_VAR constexpr __adl::get_executor_fn executor
std::experimental::coroutine_handle< promise_type > coro_
static ViaCoroutine create(folly::Executor *executor)
folly::Executor * executor_
ViaIfAsyncAwaiter(folly::Executor *executor, Awaitable &&awaitable)
ViaIfAsyncAwaiter(folly::InlineExecutor *, Awaitable &&awaitable)
std::experimental::coroutine_handle getWrappedCoroutine(std::experimental::coroutine_handle<> continuation) noexcept
T exchange(T &obj, U &&new_value)
void unhandled_exception() noexcept
std::experimental::suspend_always initial_suspend()
static ViaCoroutine createInline() noexcept
detail::ViaCoroutine viaCoroutine_
Awaitable & get_awaiter(Awaitable &&awaitable)
uint64_t value(const typename LockFreeRingBuffer< T, Atom >::Cursor &rbcursor)
void return_void() noexcept
ViaCoroutine(std::experimental::coroutine_handle< promise_type > coro) noexcept
void swap(SwapTrackingAlloc< T > &, SwapTrackingAlloc< T > &)
promise_type(folly::Executor *executor) noexcept
void swap(ViaCoroutine &other) noexcept
ViaCoroutine & operator=(ViaCoroutine other) noexcept
ViaIfAsyncAwaitable(folly::Executor *executor, Awaitable &&awaitable) noexcept(std::is_nothrow_move_constructible< Awaitable >::value)