proxygen
folly::coro::detail::TaskPromiseBase Class Reference

#include <Task.h>

Inheritance diagram for folly::coro::detail::TaskPromiseBase:
folly::coro::detail::TaskPromise< T > folly::coro::detail::TaskPromise< void >

Classes

class  FinalAwaiter
 

Public Member Functions

std::experimental::suspend_always initial_suspend () noexcept
 
FinalAwaiter final_suspend () noexcept
 
template<typename U >
auto await_transform (Task< U > &&t) noexcept
 
template<typename Awaitable >
auto await_transform (Awaitable &&awaitable) noexcept
 
auto await_transform (folly::coro::getCurrentExecutor) noexcept
 
template<typename T >
auto await_transform (Task< T > &&t) noexcept
 

Protected Member Functions

 TaskPromiseBase () noexcept
 

Private Attributes

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

Friends

class FinalAwaiter
 
template<typename T >
class folly::coro::TaskWithExecutor
 
template<typename T >
class folly::coro::Task
 

Detailed Description

Definition at line 45 of file Task.h.

Constructor & Destructor Documentation

folly::coro::detail::TaskPromiseBase::TaskPromiseBase ( )
inlineprotectednoexcept

Definition at line 65 of file Task.h.

65 : executor_(nullptr) {}
folly::Executor * executor_
Definition: Task.h:97

Member Function Documentation

template<typename U >
auto folly::coro::detail::TaskPromiseBase::await_transform ( Task< U > &&  t)
noexcept
template<typename Awaitable >
auto folly::coro::detail::TaskPromiseBase::await_transform ( Awaitable &&  awaitable)
inlinenoexcept

Definition at line 80 of file Task.h.

References folly::coro::co_viaIfAsync().

80  {
82  return co_viaIfAsync(executor_, static_cast<Awaitable&&>(awaitable));
83  }
auto co_viaIfAsync(folly::Executor *executor, Awaitable &&awaitable) -> ViaIfAsyncAwaitable< Awaitable >
Definition: ViaIfAsync.h:247
folly::Executor * executor_
Definition: Task.h:97
auto folly::coro::detail::TaskPromiseBase::await_transform ( folly::coro::getCurrentExecutor  )
inlinenoexcept

Definition at line 85 of file Task.h.

85  {
86  return AwaitableReady<folly::Executor*>{executor_};
87  }
folly::Executor * executor_
Definition: Task.h:97
template<typename T >
auto folly::coro::detail::TaskPromiseBase::await_transform ( Task< T > &&  t)
noexcept

Definition at line 309 of file Task.h.

References destroy(), folly::exchange(), SCOPE_EXIT, and folly::pushmi::detail::t.

309  {
310  class Awaiter {
311  using handle_t =
312  std::experimental::coroutine_handle<detail::TaskPromise<T>>;
313 
314  public:
315  explicit Awaiter(handle_t coro) noexcept : coro_(coro) {}
316 
317  Awaiter(Awaiter&& other) noexcept : coro_(std::exchange(other.coro_, {})) {}
318 
319  Awaiter(const Awaiter&) = delete;
320 
321  ~Awaiter() {
322  if (coro_) {
323  coro_.destroy();
324  }
325  }
326 
327  bool await_ready() noexcept {
328  return false;
329  }
330 
331  handle_t await_suspend(
332  std::experimental::coroutine_handle<> continuation) noexcept {
333  coro_.promise().continuation_ = continuation;
334  return coro_;
335  }
336 
337  decltype(auto) await_resume() {
338  SCOPE_EXIT {
339  std::exchange(coro_, {}).destroy();
340  };
341  return coro_.promise().getResult();
342  }
343 
344  private:
345  handle_t coro_;
346  };
347 
348  t.coro_.promise().executor_ = executor_;
349  return Awaiter{std::exchange(t.coro_, {})};
350 }
STL namespace.
#define SCOPE_EXIT
Definition: ScopeGuard.h:274
requires E e noexcept(noexcept(s.error(std::move(e))))
static void destroy()
folly::Executor * executor_
Definition: Task.h:97
T exchange(T &obj, U &&new_value)
Definition: Utility.h:120
FinalAwaiter folly::coro::detail::TaskPromiseBase::final_suspend ( )
inlinenoexcept

Definition at line 72 of file Task.h.

References folly::pushmi::__adl::noexcept(), and folly::pushmi::detail::t.

72  {
73  return {};
74  }
std::experimental::suspend_always folly::coro::detail::TaskPromiseBase::initial_suspend ( )
inlinenoexcept

Definition at line 68 of file Task.h.

68  {
69  return {};
70  }

Friends And Related Function Documentation

friend class FinalAwaiter
friend

Definition at line 62 of file Task.h.

template<typename T >
friend class folly::coro::Task
friend

Definition at line 94 of file Task.h.

template<typename T >
friend class folly::coro::TaskWithExecutor
friend

Definition at line 91 of file Task.h.

Member Data Documentation

std::experimental::coroutine_handle folly::coro::detail::TaskPromiseBase::continuation_
private
folly::Executor* folly::coro::detail::TaskPromiseBase::executor_
private

Definition at line 97 of file Task.h.


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