proxygen
folly::coro::detail::ViaCoroutine::promise_type Class Reference

#include <ViaIfAsync.h>

Public Member Functions

 promise_type (folly::Executor *executor) noexcept
 
ViaCoroutine get_return_object () noexcept
 
std::experimental::suspend_always initial_suspend ()
 
auto final_suspend ()
 
void unhandled_exception () noexcept
 
void return_void () noexcept
 
void setContinuation (std::experimental::coroutine_handle<> continuation) noexcept
 

Private Attributes

folly::Executorexecutor_
 
std::experimental::coroutine_handle continuation_
 

Detailed Description

Definition at line 36 of file ViaIfAsync.h.

Constructor & Destructor Documentation

folly::coro::detail::ViaCoroutine::promise_type::promise_type ( folly::Executor executor)
inlinenoexcept

Definition at line 38 of file ViaIfAsync.h.

38 : executor_(executor) {}

Member Function Documentation

auto folly::coro::detail::ViaCoroutine::promise_type::final_suspend ( )
inline

Definition at line 50 of file ViaIfAsync.h.

References folly::pushmi::__adl::noexcept().

50  {
51  struct Awaiter {
52  bool await_ready() noexcept {
53  return false;
54  }
55  void await_suspend(
56  std::experimental::coroutine_handle<promise_type> coro) noexcept {
57  // Schedule resumption of the coroutine on the executor.
58  auto& promise = coro.promise();
59  promise.executor_->add(promise.continuation_);
60  }
61  void await_resume() noexcept {}
62  };
63 
64  return Awaiter{};
65  }
requires E e noexcept(noexcept(s.error(std::move(e))))
ViaCoroutine folly::coro::detail::ViaCoroutine::promise_type::get_return_object ( )
inlinenoexcept

Definition at line 40 of file ViaIfAsync.h.

40  {
41  return ViaCoroutine{
42  std::experimental::coroutine_handle<promise_type>::from_promise(
43  *this)};
44  }
ViaCoroutine(ViaCoroutine &&other) noexcept
Definition: ViaIfAsync.h:84
std::experimental::suspend_always folly::coro::detail::ViaCoroutine::promise_type::initial_suspend ( )
inline

Definition at line 46 of file ViaIfAsync.h.

46  {
47  return {};
48  }
void folly::coro::detail::ViaCoroutine::promise_type::return_void ( )
inlinenoexcept

Definition at line 71 of file ViaIfAsync.h.

71 {}
void folly::coro::detail::ViaCoroutine::promise_type::setContinuation ( std::experimental::coroutine_handle<>  continuation)
inlinenoexcept

Definition at line 73 of file ViaIfAsync.h.

References continuation_.

74  {
75  DCHECK(!continuation_);
76  continuation_ = continuation;
77  }
std::experimental::coroutine_handle continuation_
Definition: ViaIfAsync.h:81
void folly::coro::detail::ViaCoroutine::promise_type::unhandled_exception ( )
inlinenoexcept

Definition at line 67 of file ViaIfAsync.h.

References folly::FATAL.

67  {
68  LOG(FATAL) << "ViaCoroutine threw an unhandled exception";
69  }

Member Data Documentation

std::experimental::coroutine_handle folly::coro::detail::ViaCoroutine::promise_type::continuation_
private

Definition at line 81 of file ViaIfAsync.h.

Referenced by setContinuation().

folly::Executor* folly::coro::detail::ViaCoroutine::promise_type::executor_
private

Definition at line 80 of file ViaIfAsync.h.


The documentation for this class was generated from the following file: