proxygen
ImmediateFlowSingleSender Class Reference
Inheritance diagram for ImmediateFlowSingleSender:
testing::Test

Protected Member Functions

auto make_producer ()
 
template<class F >
auto make_consumer (F f)
 
- Protected Member Functions inherited from testing::Test
 Test ()
 
virtual void SetUp ()
 
virtual void TearDown ()
 
 Test ()
 
virtual void SetUp ()
 
virtual void TearDown ()
 
 Test ()
 
virtual void SetUp ()
 
virtual void TearDown ()
 

Protected Attributes

int signals_ {0}
 

Additional Inherited Members

- Public Types inherited from testing::Test
typedef internal::SetUpTestCaseFunc SetUpTestCaseFunc
 
typedef internal::TearDownTestCaseFunc TearDownTestCaseFunc
 
typedef internal::SetUpTestCaseFunc SetUpTestCaseFunc
 
typedef internal::TearDownTestCaseFunc TearDownTestCaseFunc
 
typedef internal::SetUpTestCaseFunc SetUpTestCaseFunc
 
typedef internal::TearDownTestCaseFunc TearDownTestCaseFunc
 
- Public Member Functions inherited from testing::Test
virtual ~Test ()
 
virtual ~Test ()
 
virtual ~Test ()
 
- Static Public Member Functions inherited from testing::Test
static void SetUpTestCase ()
 
static void TearDownTestCase ()
 
static bool HasFatalFailure ()
 
static bool HasNonfatalFailure ()
 
static bool HasFailure ()
 
static void RecordProperty (const std::string &key, const std::string &value)
 
static void RecordProperty (const std::string &key, int value)
 
static void SetUpTestCase ()
 
static void TearDownTestCase ()
 
static bool HasFatalFailure ()
 
static bool HasNonfatalFailure ()
 
static bool HasFailure ()
 
static void RecordProperty (const std::string &key, const std::string &value)
 
static void RecordProperty (const std::string &key, int value)
 
static void SetUpTestCase ()
 
static void TearDownTestCase ()
 
static bool HasFatalFailure ()
 
static bool HasNonfatalFailure ()
 
static bool HasFailure ()
 
static void RecordProperty (const std::string &key, const std::string &value)
 
static void RecordProperty (const std::string &key, int value)
 

Detailed Description

Definition at line 45 of file FlowTest.cpp.

Member Function Documentation

template<class F >
auto ImmediateFlowSingleSender::make_consumer ( f)
inlineprotected

Definition at line 91 of file FlowTest.cpp.

References f, MAKE, folly::gen::move, folly::pushmi::__adl::noexcept(), folly::pushmi::on_done(), folly::pushmi::on_error(), folly::pushmi::on_starting(), and folly::pushmi::on_value().

91  {
92  return mi::MAKE(flow_receiver)(
93  mi::on_value([&](int) { signals_ += 100; }),
94  mi::on_error([&](auto) noexcept { signals_ += 1000; }),
95  mi::on_done([&]() { signals_ += 1; }),
96  mi::on_starting([&, f](auto up) {
97  signals_ += 10;
98  f(std::move(up));
99  }));
100  }
auto f
auto on_value(Fns...fns) -> on_value_fn< Fns... >
Definition: boosters.h:262
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
auto on_error(Fns...fns) -> on_error_fn< Fns... >
Definition: boosters.h:273
auto on_starting(Fns...fns) -> on_starting_fn< Fns... >
Definition: boosters.h:296
requires E e noexcept(noexcept(s.error(std::move(e))))
#define MAKE(x)
Definition: FlowTest.cpp:42
auto on_done(Fn fn) -> on_done_fn< Fn >
Definition: boosters.h:285
auto ImmediateFlowSingleSender::make_producer ( )
inlineprotected

Definition at line 47 of file FlowTest.cpp.

References data, folly::pushmi::lock_both(), MAKE, folly::gen::move, folly::pushmi::__adl::noexcept(), folly::pushmi::on_done(), folly::pushmi::set_done, folly::pushmi::set_starting, folly::pushmi::set_value, folly::pushmi::shared_entangle(), stop(), and tokens.

47  {
48  return mi::MAKE(flow_single_sender)([&](auto out) {
49  // boolean cancellation
50  bool stop = false;
51  auto set_stop = [](auto& stop) {
52  if (!!stop) {
53  *stop = true;
54  }
55  };
56  auto tokens = mi::shared_entangle(stop, set_stop);
57 
58  using Stopper = decltype(tokens.second);
59  struct Data : mi::receiver<> {
60  explicit Data(Stopper stopper) : stopper(std::move(stopper)) {}
61  Stopper stopper;
62  };
63  auto up = mi::MAKE(receiver)(
64  Data{std::move(tokens.second)},
65  [&](auto& data, auto) noexcept {
66  signals_ += 100000;
67  auto both = lock_both(data.stopper);
68  (*(both.first))(both.second);
69  },
70  mi::on_done([&](auto& data) {
71  signals_ += 10000;
72  auto both = lock_both(data.stopper);
73  (*(both.first))(both.second);
74  }));
75 
76  // pass reference for cancellation.
77  ::mi::set_starting(out, std::move(up));
78 
79  // check boolean to select signal
80  auto both = lock_both(tokens.first);
81  if (!!both.first && !*(both.first)) {
82  ::mi::set_value(out, 42);
83  } else {
84  // cancellation is not an error
85  ::mi::set_done(out);
86  }
87  });
88  }
locked_entangled_pair< T, Dual > lock_both(entangled< T, Dual > &e)
Definition: entangle.h:257
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
STL namespace.
requires E e noexcept(noexcept(s.error(std::move(e))))
#define MAKE(x)
Definition: FlowTest.cpp:42
auto shared_entangle(First f, Second s) -> shared_entangled_pair< First, Second >
Definition: entangle.h:279
static void stop()
PUSHMI_INLINE_VAR constexpr __adl::set_starting_fn set_starting
auto on_done(Fn fn) -> on_done_fn< Fn >
Definition: boosters.h:285
PUSHMI_INLINE_VAR constexpr __adl::set_value_fn set_value
static constexpr uint64_t data[1]
Definition: Fingerprint.cpp:43
static const char tokens[256]
Definition: http_parser.c:184
PUSHMI_INLINE_VAR constexpr __adl::set_done_fn set_done

Member Data Documentation

int ImmediateFlowSingleSender::signals_ {0}
protected

Definition at line 102 of file FlowTest.cpp.


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