proxygen
folly::futures::detail::CoreCallbackState< T, F > Class Template Reference

#include <Future-inl.h>

Public Member Functions

 CoreCallbackState (Promise< T > &&promise, F &&func) noexcept(noexcept(DF(std::declval< F && >())))
 
 CoreCallbackState (CoreCallbackState &&that) noexcept(noexcept(DF(std::declval< F && >())))
 
CoreCallbackStateoperator= (CoreCallbackState &&)=delete
 
 ~CoreCallbackState ()
 
template<typename... Args>
auto invoke (Args &&...args) noexcept(noexcept(std::declval< F && >()(std::declval< Args && >()...)))
 
template<typename... Args>
auto tryInvoke (Args &&...args) noexcept
 
void setTry (Try< T > &&t)
 
void setException (exception_wrapper &&ew)
 
Promise< TstealPromise () noexcept
 

Private Types

using DF = _t< std::decay< F >>
 

Private Member Functions

bool before_barrier () const noexcept
 

Private Attributes

union {
   DF   func_
 
}; 
 
Promise< Tpromise_ {Promise<T>::makeEmpty()}
 

Detailed Description

template<typename T, typename F>
class folly::futures::detail::CoreCallbackState< T, F >

Definition at line 61 of file Future-inl.h.

Member Typedef Documentation

template<typename T , typename F >
using folly::futures::detail::CoreCallbackState< T, F >::DF = _t<std::decay<F>>
private

Definition at line 62 of file Future-inl.h.

Constructor & Destructor Documentation

template<typename T , typename F >
folly::futures::detail::CoreCallbackState< T, F >::CoreCallbackState ( Promise< T > &&  promise,
F &&  func 
)
inlinenoexcept

Definition at line 65 of file Future-inl.h.

67  : func_(std::forward<F>(func)), promise_(std::move(promise)) {
68  assert(before_barrier());
69  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
template<typename T , typename F >
folly::futures::detail::CoreCallbackState< T, F >::CoreCallbackState ( CoreCallbackState< T, F > &&  that)
inlinenoexcept

Definition at line 71 of file Future-inl.h.

References promise_.

72  {
73  if (that.before_barrier()) {
74  new (&func_) DF(std::forward<F>(that.func_));
75  promise_ = that.stealPromise();
76  }
77  }
template<typename T , typename F >
folly::futures::detail::CoreCallbackState< T, F >::~CoreCallbackState ( )
inline

Definition at line 81 of file Future-inl.h.

References testing::Args().

81  {
82  if (before_barrier()) {
83  stealPromise();
84  }
85  }
Promise< T > stealPromise() noexcept
Definition: Future-inl.h:107

Member Function Documentation

template<typename T , typename F >
bool folly::futures::detail::CoreCallbackState< T, F >::before_barrier ( ) const
inlineprivatenoexcept

Definition at line 114 of file Future-inl.h.

References promise_.

114  {
115  return !promise_.isFulfilled();
116  }
template<typename T , typename F >
template<typename... Args>
auto folly::futures::detail::CoreCallbackState< T, F >::invoke ( Args &&...  args)
inlinenoexcept

Definition at line 88 of file Future-inl.h.

References testing::Args().

89  {
90  assert(before_barrier());
91  return std::forward<F>(func_)(std::forward<Args>(args)...);
92  }
template<typename T , typename F >
CoreCallbackState& folly::futures::detail::CoreCallbackState< T, F >::operator= ( CoreCallbackState< T, F > &&  )
delete
template<typename T , typename F >
void folly::futures::detail::CoreCallbackState< T, F >::setException ( exception_wrapper &&  ew)
inline

Definition at line 103 of file Future-inl.h.

References folly::gen::move.

103  {
104  stealPromise().setException(std::move(ew));
105  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
Promise< T > stealPromise() noexcept
Definition: Future-inl.h:107
template<typename T , typename F >
void folly::futures::detail::CoreCallbackState< T, F >::setTry ( Try< T > &&  t)
inline

Definition at line 99 of file Future-inl.h.

References folly::gen::move, and folly::pushmi::detail::t.

99  {
100  stealPromise().setTry(std::move(t));
101  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
Promise< T > stealPromise() noexcept
Definition: Future-inl.h:107
template<typename T , typename F >
Promise<T> folly::futures::detail::CoreCallbackState< T, F >::stealPromise ( )
inlinenoexcept

Definition at line 107 of file Future-inl.h.

References folly::gen::move, and promise_.

107  {
108  assert(before_barrier());
109  func_.~DF();
110  return std::move(promise_);
111  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
template<typename T , typename F >
template<typename... Args>
auto folly::futures::detail::CoreCallbackState< T, F >::tryInvoke ( Args &&...  args)
inlinenoexcept

Definition at line 95 of file Future-inl.h.

References folly::invoke(), and folly::makeTryWith().

95  {
96  return makeTryWith([&] { return invoke(std::forward<Args>(args)...); });
97  }
auto invoke(Args &&...args) noexcept(noexcept(std::declval< F && >()(std::declval< Args && >()...)))
Definition: Future-inl.h:88
std::enable_if< !std::is_same< invoke_result_t< F >, void >::value, Try< invoke_result_t< F > > >::type makeTryWith(F &&f)
Definition: Try-inl.h:223

Member Data Documentation

union { ... }
template<typename T , typename F >
DF folly::futures::detail::CoreCallbackState< T, F >::func_

Definition at line 119 of file Future-inl.h.

template<typename T , typename F >
Promise<T> folly::futures::detail::CoreCallbackState< T, F >::promise_ {Promise<T>::makeEmpty()}
private

Definition at line 121 of file Future-inl.h.


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