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

#include <Task.h>

Classes

class  Awaiter
 

Public Member Functions

 ~TaskWithExecutor ()
 
 TaskWithExecutor (TaskWithExecutor &&t) noexcept
 
TaskWithExecutoroperator= (TaskWithExecutor t) noexcept
 
folly::Executorexecutor () const noexcept
 
void swap (TaskWithExecutor &t) noexcept
 
auto start ()&&
 
Awaiter operator co_await ()&&noexcept
 

Private Types

using handle_t = std::experimental::coroutine_handle< detail::TaskPromise< T >>
 

Private Member Functions

 TaskWithExecutor (handle_t coro) noexcept
 

Private Attributes

handle_t coro_
 

Friends

class Task< T >
 

Detailed Description

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

Represents an allocated but not yet started coroutine that has already been bound to an executor.

This task, when co_awaited, will launch the task on the bound executor and will resume the awaiting coroutine on the bound executor when it completes.

Definition at line 41 of file Task.h.

Member Typedef Documentation

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

Definition at line 165 of file Task.h.

Constructor & Destructor Documentation

template<typename T >
folly::coro::TaskWithExecutor< T >::~TaskWithExecutor ( )
inline

Definition at line 168 of file Task.h.

168  {
169  if (coro_) {
170  coro_.destroy();
171  }
172  }
template<typename T >
folly::coro::TaskWithExecutor< T >::TaskWithExecutor ( TaskWithExecutor< T > &&  t)
inlinenoexcept

Definition at line 174 of file Task.h.

175  : coro_(std::exchange(t.coro_, {})) {}
T exchange(T &obj, U &&new_value)
Definition: Utility.h:120
template<typename T >
folly::coro::TaskWithExecutor< T >::TaskWithExecutor ( handle_t  coro)
inlineexplicitprivatenoexcept

Definition at line 239 of file Task.h.

239 : coro_(coro) {}

Member Function Documentation

template<typename T >
folly::Executor* folly::coro::TaskWithExecutor< T >::executor ( ) const
inlinenoexcept

Definition at line 182 of file Task.h.

182  {
183  return coro_.promise().executor_;
184  }
template<typename T >
Awaiter folly::coro::TaskWithExecutor< T >::operator co_await ( )
inlinenoexcept

Definition at line 232 of file Task.h.

References folly::exchange().

232  {
233  return Awaiter{std::exchange(coro_, {})};
234  }
T exchange(T &obj, U &&new_value)
Definition: Utility.h:120
template<typename T >
TaskWithExecutor& folly::coro::TaskWithExecutor< T >::operator= ( TaskWithExecutor< T t)
inlinenoexcept

Definition at line 177 of file Task.h.

References folly::swap(), and folly::pushmi::detail::t.

177  {
178  swap(t);
179  return *this;
180  }
void swap(TaskWithExecutor &t) noexcept
Definition: Task.h:186
template<typename T >
auto folly::coro::TaskWithExecutor< T >::start ( )
inline

Definition at line 192 of file Task.h.

References folly::gen::move.

192  {
193  return folly::coro::toSemiFuture(std::move(*this));
194  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
template<typename T >
void folly::coro::TaskWithExecutor< T >::swap ( TaskWithExecutor< T > &  t)
inlinenoexcept

Definition at line 186 of file Task.h.

References folly::f14::swap(), and folly::pushmi::detail::t.

186  {
187  std::swap(coro_, t.coro_);
188  }
void swap(SwapTrackingAlloc< T > &, SwapTrackingAlloc< T > &)
Definition: F14TestUtil.h:414

Friends And Related Function Documentation

template<typename T >
friend class Task< T >
friend

Definition at line 237 of file Task.h.

Member Data Documentation

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

Definition at line 241 of file Task.h.


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