proxygen
folly::pushmi::subject< PS, TN... >::subject_shared Struct Reference

#include <subject.h>

Public Types

using receiver_t = any_receiver< std::exception_ptr, TN... >
 

Public Member Functions

requires Receiver< Out > void submit (Out out)
 
requires And< SemiMovable< VN >... > void value (VN &&...vn)
 
requires SemiMovable< E > void error (E e) noexcept
 
void done ()
 

Public Attributes

bool done_ = false
 
::folly::pushmi::detail::opt< std::tuple< std::decay_t< TN >... > > t_
 
std::exception_ptr ep_
 
std::vector< receiver_treceivers_
 
std::mutex lock_
 

Detailed Description

template<class PS, class... TN>
struct folly::pushmi::subject< PS, TN... >::subject_shared

Definition at line 35 of file subject.h.

Member Typedef Documentation

template<class PS , class... TN>
using folly::pushmi::subject< PS, TN... >::subject_shared::receiver_t = any_receiver<std::exception_ptr, TN...>

Definition at line 36 of file subject.h.

Member Function Documentation

template<class PS , class... TN>
void folly::pushmi::subject< PS, TN... >::subject_shared::done ( )
inline

Definition at line 86 of file subject.h.

References folly::gen::guard(), and folly::pushmi::set_done.

86  {
87  std::unique_lock<std::mutex> guard(lock_);
88  done_ = true;
89  for (auto& out : receivers_) {
90  set_done(out);
91  }
92  receivers_.clear();
93  }
GuardImpl guard(ErrorHandler &&handler)
Definition: Base.h:840
PUSHMI_INLINE_VAR constexpr __adl::set_done_fn set_done
template<class PS , class... TN>
requires SemiMovable<E> void folly::pushmi::subject< PS, TN... >::subject_shared::error ( E  e)
inlinenoexcept

Definition at line 78 of file subject.h.

References folly::gen::guard(), folly::gen::move, and folly::pushmi::set_error.

78  {
79  std::unique_lock<std::mutex> guard(lock_);
80  ep_ = e;
81  for (auto& out : receivers_) {
82  set_error(out, std::move(e));
83  }
84  receivers_.clear();
85  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
PUSHMI_INLINE_VAR constexpr __adl::set_error_fn set_error
GuardImpl guard(ErrorHandler &&handler)
Definition: Base.h:840
template<class PS , class... TN>
requires Receiver<Out> void folly::pushmi::subject< PS, TN... >::subject_shared::submit ( Out  out)
inline

Definition at line 44 of file subject.h.

References folly::apply(), folly::gen::guard(), folly::gen::move, folly::pushmi::PUSHMI_TEMPLATE(), folly::pushmi::requires(), folly::pushmi::set_done, folly::pushmi::set_error, and folly::pushmi::set_value.

44  {
45  std::unique_lock<std::mutex> guard(lock_);
46  if (ep_) {
47  set_error(out, ep_);
48  return;
49  }
50  if (!!t_) {
51  auto args = *t_;
54  std::tuple_cat(std::tuple<Out>{std::move(out)}, std::move(args)));
55  return;
56  }
57  if (done_) {
58  set_done(out);
59  return;
60  }
61  receivers_.push_back(receiver_t{out});
62  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
PUSHMI_INLINE_VAR constexpr __adl::set_error_fn set_error
::folly::pushmi::detail::opt< std::tuple< std::decay_t< TN >... > > t_
Definition: subject.h:38
any_receiver< std::exception_ptr, TN... > receiver_t
Definition: subject.h:36
GuardImpl guard(ErrorHandler &&handler)
Definition: Base.h:840
PUSHMI_INLINE_VAR constexpr __adl::set_value_fn set_value
decltype(auto) constexpr apply(F &&func, Tuple &&tuple)
Definition: ApplyTuple.h:87
PUSHMI_INLINE_VAR constexpr __adl::set_done_fn set_done
template<class PS , class... TN>
requires And<SemiMovable<VN>...> void folly::pushmi::subject< PS, TN... >::subject_shared::value ( VN &&...  vn)
inline

Definition at line 65 of file subject.h.

References folly::apply(), folly::pushmi::detail::as_const, folly::gen::guard(), std::tr1::make_tuple(), folly::pushmi::PUSHMI_TEMPLATE(), folly::pushmi::requires(), and folly::pushmi::set_value.

65  {
66  std::unique_lock<std::mutex> guard(lock_);
67  for (auto& out : receivers_) {
70  std::tuple<decltype(out), std::decay_t<TN>...>{
71  out, detail::as_const(vn)...});
72  }
73  t_ = std::make_tuple((VN &&) vn...);
74  receivers_.clear();
75  }
::folly::pushmi::detail::opt< std::tuple< std::decay_t< TN >... > > t_
Definition: subject.h:38
tuple make_tuple()
Definition: gtest-tuple.h:675
GuardImpl guard(ErrorHandler &&handler)
Definition: Base.h:840
PUSHMI_INLINE_VAR constexpr struct folly::pushmi::detail::as_const_fn as_const
PUSHMI_INLINE_VAR constexpr __adl::set_value_fn set_value
decltype(auto) constexpr apply(F &&func, Tuple &&tuple)
Definition: ApplyTuple.h:87

Member Data Documentation

template<class PS , class... TN>
bool folly::pushmi::subject< PS, TN... >::subject_shared::done_ = false

Definition at line 37 of file subject.h.

template<class PS , class... TN>
std::exception_ptr folly::pushmi::subject< PS, TN... >::subject_shared::ep_

Definition at line 39 of file subject.h.

template<class PS , class... TN>
std::mutex folly::pushmi::subject< PS, TN... >::subject_shared::lock_

Definition at line 41 of file subject.h.

template<class PS , class... TN>
std::vector<receiver_t> folly::pushmi::subject< PS, TN... >::subject_shared::receivers_

Definition at line 40 of file subject.h.

template<class PS , class... TN>
::folly::pushmi::detail::opt<std::tuple<std::decay_t<TN>...> > folly::pushmi::subject< PS, TN... >::subject_shared::t_

Definition at line 38 of file subject.h.


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