proxygen
folly::coro::detail::InlineTask< T > Class Template Reference

#include <InlineTask.h>

Classes

class  Awaiter
 

Public Types

using promise_type = detail::InlineTaskPromise< T >
 

Public Member Functions

 InlineTask (InlineTask &&other) noexcept
 
 ~InlineTask ()
 
Awaiter operator co_await ()&&
 

Private Types

using handle_t = std::experimental::coroutine_handle< promise_type >
 

Private Member Functions

 InlineTask (handle_t coro) noexcept
 

Private Attributes

handle_t coro_
 

Friends

class InlineTaskPromise< T >
 

Detailed Description

template<typename T>
class folly::coro::detail::InlineTask< T >

InlineTask<T> is a coroutine-return type where the coroutine is launched inline in the current execution context when it is co_awaited and the task's continuation is launched inline in the execution context that the task completed on.

This task type is primarily intended as a building block for certain coroutine operators. It is not intended for general use in application code or in library interfaces exposed to library code as it can easily be abused to accidentally run logic on the wrong execution context.

For this reason, the InlineTask<T> type has been placed inside the folly::coro::detail namespace to discourage general usage.

Definition at line 42 of file InlineTask.h.

Member Typedef Documentation

template<typename T>
using folly::coro::detail::InlineTask< T >::handle_t = std::experimental::coroutine_handle<promise_type>
private

Definition at line 166 of file InlineTask.h.

Definition at line 163 of file InlineTask.h.

Constructor & Destructor Documentation

template<typename T>
folly::coro::detail::InlineTask< T >::InlineTask ( InlineTask< T > &&  other)
inlinenoexcept

Definition at line 169 of file InlineTask.h.

170  : coro_(std::exchange(other.coro_, {})) {}
T exchange(T &obj, U &&new_value)
Definition: Utility.h:120
template<typename T>
folly::coro::detail::InlineTask< T >::~InlineTask ( )
inline

Definition at line 172 of file InlineTask.h.

172  {
173  if (coro_) {
174  coro_.destroy();
175  }
176  }
template<typename T>
folly::coro::detail::InlineTask< T >::InlineTask ( handle_t  coro)
inlineexplicitprivatenoexcept

Definition at line 216 of file InlineTask.h.

216 : coro_(coro) {}

Member Function Documentation

template<typename T>
Awaiter folly::coro::detail::InlineTask< T >::operator co_await ( )
inline

Definition at line 209 of file InlineTask.h.

References folly::exchange().

209  {
210  assert(coro_ && !coro_.done());
211  return Awaiter{std::exchange(coro_, {})};
212  }
T exchange(T &obj, U &&new_value)
Definition: Utility.h:120

Friends And Related Function Documentation

template<typename T>
friend class InlineTaskPromise< T >
friend

Definition at line 215 of file InlineTask.h.

Member Data Documentation

template<typename T>
handle_t folly::coro::detail::InlineTask< T >::coro_
private

Definition at line 217 of file InlineTask.h.


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