proxygen
folly::pushmi::any_flow_receiver< PE, PV, E, VN > Class Template Reference

#include <flow_receiver.h>

Classes

union  data
 
struct  vtable
 

Public Types

using properties = property_set< is_receiver<>, is_flow<>>
 

Public Member Functions

 any_flow_receiver ()=default
 
 any_flow_receiver (any_flow_receiver &&that) noexcept
 
requires FlowUpTo< wrapped_t< Wrapped >, any_receiver< PE, PV > > &&ReceiveValue< wrapped_t< Wrapped >, VN... > &&ReceiveError< wrapped_t< Wrapped >, Eany_flow_receiver (Wrapped obj) noexcept(insitu< Wrapped >())
 
 ~any_flow_receiver ()
 
any_flow_receiveroperator= (any_flow_receiver &&that) noexcept
 
void value (VN...vn)
 
void error (E e) noexcept
 
void done ()
 
void starting (any_receiver< PE, PV > up)
 

Private Types

template<class T , class U = std::decay_t<T>>
using wrapped_t = std::enable_if_t<!std::is_same< U, any_flow_receiver >::value, U >
 

Private Member Functions

template<class Wrapped >
 any_flow_receiver (Wrapped obj, std::false_type)
 
template<class Wrapped >
 any_flow_receiver (Wrapped obj, std::true_type) noexcept
 

Static Private Member Functions

template<class Wrapped >
static constexpr bool insitu ()
 

Private Attributes

bool done_ = false
 
bool started_ = false
 
union folly::pushmi::any_flow_receiver::data data_
 
vtable const * vptr_ = &noop_
 

Static Private Attributes

static constexpr vtable const noop_ {}
 

Detailed Description

template<class PE, class PV, class E, class... VN>
class folly::pushmi::any_flow_receiver< PE, PV, E, VN >

Definition at line 24 of file flow_receiver.h.

Member Typedef Documentation

template<class PE, class PV, class E, class... VN>
using folly::pushmi::any_flow_receiver< PE, PV, E, VN >::properties = property_set<is_receiver<>, is_flow<>>

Definition at line 105 of file flow_receiver.h.

template<class PE, class PV, class E, class... VN>
template<class T , class U = std::decay_t<T>>
using folly::pushmi::any_flow_receiver< PE, PV, E, VN >::wrapped_t = std::enable_if_t<!std::is_same<U, any_flow_receiver>::value, U>
private

Definition at line 103 of file flow_receiver.h.

Constructor & Destructor Documentation

template<class PE, class PV, class E, class... VN>
template<class Wrapped >
folly::pushmi::any_flow_receiver< PE, PV, E, VN >::any_flow_receiver ( Wrapped  obj,
std::false_type   
)
inlineprivate

Definition at line 51 of file flow_receiver.h.

References upload::const, folly::pushmi::any_flow_receiver< PE, PV, E, VN >::data_, folly::pushmi::any_flow_receiver< PE, PV, E, VN >::done(), folly::pushmi::operators::error(), folly::pushmi::any_flow_receiver< PE, PV, E, VN >::error(), folly::exchange(), folly::gen::move, folly::pushmi::__adl::noexcept(), folly::pushmi::any_flow_receiver< PE, PV, E, VN >::data::pobj_, s, folly::pushmi::set_done, folly::pushmi::set_error, folly::pushmi::set_starting, folly::pushmi::set_value, folly::pushmi::any_flow_receiver< PE, PV, E, VN >::starting(), value, and folly::pushmi::any_flow_receiver< PE, PV, E, VN >::value().

51  : any_flow_receiver() {
52  struct s {
53  static void op(data& src, data* dst) {
54  if (dst)
55  dst->pobj_ = std::exchange(src.pobj_, nullptr);
56  delete static_cast<Wrapped const*>(src.pobj_);
57  }
58  static void done(data& src) {
59  set_done(*static_cast<Wrapped*>(src.pobj_));
60  }
61  static void error(data& src, E e) noexcept {
62  set_error(*static_cast<Wrapped*>(src.pobj_), std::move(e));
63  }
64  static void value(data& src, VN... vn) {
65  set_value(*static_cast<Wrapped*>(src.pobj_), std::move(vn)...);
66  }
67  static void starting(data& src, any_receiver<PE, PV> up) {
68  set_starting(*static_cast<Wrapped*>(src.pobj_), std::move(up));
69  }
70  };
71  static const vtable vtbl{s::op, s::done, s::error, s::value, s::starting};
72  data_.pobj_ = new Wrapped(std::move(obj));
73  vptr_ = &vtbl;
74  }
void starting(any_receiver< PE, PV > up)
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
PUSHMI_INLINE_VAR constexpr __adl::set_error_fn set_error
requires E e noexcept(noexcept(s.error(std::move(e))))
requires And< SemiMovable< VN >... > &&SemiMovable< E > auto error(E e)
Definition: error.h:48
constexpr auto data(C &c) -> decltype(c.data())
Definition: Access.h:71
static const char *const value
Definition: Conv.cpp:50
union folly::pushmi::any_flow_receiver::data data_
PUSHMI_INLINE_VAR constexpr __adl::set_starting_fn set_starting
T exchange(T &obj, U &&new_value)
Definition: Utility.h:120
PUSHMI_INLINE_VAR constexpr __adl::set_value_fn set_value
static set< string > s
const
Definition: upload.py:398
PUSHMI_INLINE_VAR constexpr __adl::set_done_fn set_done
template<class PE, class PV, class E, class... VN>
template<class Wrapped >
folly::pushmi::any_flow_receiver< PE, PV, E, VN >::any_flow_receiver ( Wrapped  obj,
std::true_type   
)
inlineprivatenoexcept

Definition at line 76 of file flow_receiver.h.

References folly::pushmi::any_flow_receiver< PE, PV, E, VN >::data::buffer_, upload::const, folly::pushmi::any_flow_receiver< PE, PV, E, VN >::data_, folly::pushmi::any_flow_receiver< PE, PV, E, VN >::done(), folly::pushmi::operators::error(), folly::pushmi::any_flow_receiver< PE, PV, E, VN >::error(), folly::gen::move, folly::pushmi::__adl::noexcept(), s, folly::pushmi::set_done, folly::pushmi::set_error, folly::pushmi::set_starting, folly::pushmi::set_value, folly::pushmi::any_flow_receiver< PE, PV, E, VN >::starting(), value, and folly::pushmi::any_flow_receiver< PE, PV, E, VN >::value().

76  : any_flow_receiver() {
77  struct s {
78  static void op(data& src, data* dst) {
79  if (dst)
80  new (dst->buffer_) Wrapped(
81  std::move(*static_cast<Wrapped*>((void*)src.buffer_)));
82  static_cast<Wrapped const*>((void*)src.buffer_)->~Wrapped();
83  }
84  static void done(data& src) {
85  set_done(*static_cast<Wrapped*>((void*)src.buffer_));
86  }
87  static void error(data& src, E e) noexcept {
88  set_error(*static_cast<Wrapped*>((void*)src.buffer_), std::move(e));
89  }
90  static void value(data& src, VN... vn) {
91  set_value(*static_cast<Wrapped*>((void*)src.buffer_), std::move(vn)...);
92  }
93  static void starting(data& src, any_receiver<PE, PV> up) {
94  set_starting(*static_cast<Wrapped*>((void*)src.buffer_), std::move(up));
95  }
96  };
97  static const vtable vtbl{s::op, s::done, s::error, s::value, s::starting};
98  new (data_.buffer_) Wrapped(std::move(obj));
99  vptr_ = &vtbl;
100  }
void starting(any_receiver< PE, PV > up)
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
PUSHMI_INLINE_VAR constexpr __adl::set_error_fn set_error
requires E e noexcept(noexcept(s.error(std::move(e))))
requires And< SemiMovable< VN >... > &&SemiMovable< E > auto error(E e)
Definition: error.h:48
char buffer_[sizeof(std::tuple< VN... >)]
Definition: flow_receiver.h:29
constexpr auto data(C &c) -> decltype(c.data())
Definition: Access.h:71
static const char *const value
Definition: Conv.cpp:50
union folly::pushmi::any_flow_receiver::data data_
PUSHMI_INLINE_VAR constexpr __adl::set_starting_fn set_starting
PUSHMI_INLINE_VAR constexpr __adl::set_value_fn set_value
static set< string > s
const
Definition: upload.py:398
PUSHMI_INLINE_VAR constexpr __adl::set_done_fn set_done
template<class PE, class PV, class E, class... VN>
folly::pushmi::any_flow_receiver< PE, PV, E, VN >::any_flow_receiver ( )
default
template<class PE, class PV, class E, class... VN>
folly::pushmi::any_flow_receiver< PE, PV, E, VN >::any_flow_receiver ( any_flow_receiver< PE, PV, E, VN > &&  that)
inlinenoexcept

Definition at line 108 of file flow_receiver.h.

References folly::pushmi::any_flow_receiver< PE, PV, E, VN >::data_, folly::pushmi::any_flow_receiver< PE, PV, E, VN >::vtable::op_, folly::pushmi::PUSHMI_TEMPLATE(), folly::pushmi::requires(), folly::f14::swap(), and folly::pushmi::any_flow_receiver< PE, PV, E, VN >::vptr_.

108  : any_flow_receiver() {
109  that.vptr_->op_(that.data_, &data_);
110  std::swap(that.vptr_, vptr_);
111  }
union folly::pushmi::any_flow_receiver::data data_
void swap(SwapTrackingAlloc< T > &, SwapTrackingAlloc< T > &)
Definition: F14TestUtil.h:414
template<class PE, class PV, class E, class... VN>
requires FlowUpTo<wrapped_t<Wrapped>, any_receiver<PE, PV> >&& ReceiveValue<wrapped_t<Wrapped>, VN...>&& ReceiveError<wrapped_t<Wrapped>, E> folly::pushmi::any_flow_receiver< PE, PV, E, VN >::any_flow_receiver ( Wrapped  obj)
inlineexplicitnoexcept

Definition at line 116 of file flow_receiver.h.

References folly::gen::move.

117  : any_flow_receiver{std::move(obj), bool_<insitu<Wrapped>()>{}} {}
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
template<class PE, class PV, class E, class... VN>
folly::pushmi::any_flow_receiver< PE, PV, E, VN >::~any_flow_receiver ( )
inline

Member Function Documentation

template<class PE, class PV, class E, class... VN>
void folly::pushmi::any_flow_receiver< PE, PV, E, VN >::done ( )
inline
template<class PE, class PV, class E, class... VN>
void folly::pushmi::any_flow_receiver< PE, PV, E, VN >::error ( E  e)
inlinenoexcept

Definition at line 131 of file flow_receiver.h.

References folly::pushmi::any_flow_receiver< PE, PV, E, VN >::data_, folly::pushmi::any_flow_receiver< PE, PV, E, VN >::vtable::error_, and folly::gen::move.

Referenced by folly::pushmi::any_flow_receiver< PE, PV, E, VN >::any_flow_receiver().

131  {
132  if (!started_) {std::abort();}
133  if (done_){ return; }
134  done_ = true;
135  vptr_->error_(data_, std::move(e));
136  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
void(* error_)(data &, E) noexcept
Definition: flow_receiver.h:44
union folly::pushmi::any_flow_receiver::data data_
template<class PE, class PV, class E, class... VN>
template<class Wrapped >
static constexpr bool folly::pushmi::any_flow_receiver< PE, PV, E, VN >::insitu ( )
inlinestaticprivate

Definition at line 32 of file flow_receiver.h.

References folly::pushmi::any_flow_receiver< PE, PV, E, VN >::data::buffer_, and value.

32  {
33  return sizeof(Wrapped) <= sizeof(data::buffer_) &&
35  }
char buffer_[sizeof(std::tuple< VN... >)]
Definition: flow_receiver.h:29
static const char *const value
Definition: Conv.cpp:50
template<class PE, class PV, class E, class... VN>
any_flow_receiver& folly::pushmi::any_flow_receiver< PE, PV, E, VN >::operator= ( any_flow_receiver< PE, PV, E, VN > &&  that)
inlinenoexcept
template<class PE, class PV, class E, class... VN>
void folly::pushmi::any_flow_receiver< PE, PV, E, VN >::starting ( any_receiver< PE, PV >  up)
inline
template<class PE, class PV, class E, class... VN>
void folly::pushmi::any_flow_receiver< PE, PV, E, VN >::value ( VN...  vn)
inline

Member Data Documentation

template<class PE, class PV, class E, class... VN>
bool folly::pushmi::any_flow_receiver< PE, PV, E, VN >::done_ = false
private

Definition at line 25 of file flow_receiver.h.

template<class PE, class PV, class E, class... VN>
constexpr any_flow_receiver< PE, PV, E, VN... >::vtable const folly::pushmi::any_flow_receiver< PE, PV, E, VN >::noop_ {}
staticprivate
template<class PE, class PV, class E, class... VN>
bool folly::pushmi::any_flow_receiver< PE, PV, E, VN >::started_ = false
private

Definition at line 26 of file flow_receiver.h.

template<class PE, class PV, class E, class... VN>
vtable const* folly::pushmi::any_flow_receiver< PE, PV, E, VN >::vptr_ = &noop_
private

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