proxygen
folly::coro::TaskWithExecutor< T >::Awaiter Class Reference

#include <Task.h>

Public Member Functions

 Awaiter (handle_t coro) noexcept
 
 ~Awaiter ()
 
bool await_ready () const
 
void await_suspend (std::experimental::coroutine_handle<> continuation) noexcept
 
decltype(auto) await_resume ()
 

Private Attributes

handle_t coro_
 

Detailed Description

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

Definition at line 196 of file Task.h.

Constructor & Destructor Documentation

template<typename T >
folly::coro::TaskWithExecutor< T >::Awaiter::Awaiter ( handle_t  coro)
inlineexplicitnoexcept

Definition at line 198 of file Task.h.

198 : coro_(coro) {}
template<typename T >
folly::coro::TaskWithExecutor< T >::Awaiter::~Awaiter ( )
inline

Definition at line 200 of file Task.h.

200  {
201  if (coro_) {
202  coro_.destroy();
203  }
204  }

Member Function Documentation

template<typename T >
bool folly::coro::TaskWithExecutor< T >::Awaiter::await_ready ( ) const
inline

Definition at line 206 of file Task.h.

206  {
207  return false;
208  }
template<typename T >
decltype(auto) folly::coro::TaskWithExecutor< T >::Awaiter::await_resume ( )
inline

Definition at line 220 of file Task.h.

References destroy(), folly::exchange(), and SCOPE_EXIT.

220  {
221  // Eagerly destroy the coroutine-frame once we have retrieved the result.
222  SCOPE_EXIT {
223  std::exchange(coro_, {}).destroy();
224  };
225  return coro_.promise().getResult();
226  }
#define SCOPE_EXIT
Definition: ScopeGuard.h:274
static void destroy()
T exchange(T &obj, U &&new_value)
Definition: Utility.h:120
template<typename T >
void folly::coro::TaskWithExecutor< T >::Awaiter::await_suspend ( std::experimental::coroutine_handle<>  continuation)
inlinenoexcept

Definition at line 210 of file Task.h.

211  {
212  auto& promise = coro_.promise();
213  DCHECK(!promise.continuation_);
214  DCHECK(promise.executor_ != nullptr);
215 
216  promise.continuation_ = continuation;
217  promise.executor_->add(coro_);
218  }

Member Data Documentation

template<typename T >
handle_t folly::coro::TaskWithExecutor< T >::Awaiter::coro_
private

Definition at line 229 of file Task.h.


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