Commit c7aae68e authored by Dominik Charousset's avatar Dominik Charousset

Make await_data customizable by making it virtual

parent cda62364
...@@ -302,14 +302,16 @@ public: ...@@ -302,14 +302,16 @@ public:
return fail_state_; return fail_state_;
} }
/// @cond PRIVATE // -- customization points ---------------------------------------------------
/// Blocks until at least one message is in the mailbox. /// Blocks until at least one message is in the mailbox.
void await_data(); virtual void await_data();
/// Blocks until at least one message is in the mailbox or /// Blocks until at least one message is in the mailbox or
/// the absolute `timeout` was reached. /// the absolute `timeout` was reached.
bool await_data(timeout_type timeout); virtual bool await_data(timeout_type timeout);
/// @cond PRIVATE
/// Receives messages until either a pre- or postcheck of `rcc` fails. /// Receives messages until either a pre- or postcheck of `rcc` fails.
template <class... Ts> template <class... Ts>
...@@ -325,12 +327,12 @@ public: ...@@ -325,12 +327,12 @@ public:
is_timeout_or_catch_all is_timeout_or_catch_all
>::type; >::type;
filtered tk; filtered tk;
behavior bhvr{apply_args(make_behavior_impl, get_indices(tk), tup)}; behavior bhvr{apply_moved_args(make_behavior_impl, get_indices(tk), tup)};
using tail_indices = typename il_range< using tail_indices = typename il_range<
tl_size<filtered>::value, sizeof...(Ts) tl_size<filtered>::value, sizeof...(Ts)
>::type; >::type;
make_blocking_behavior_t factory; make_blocking_behavior_t factory;
auto fun = apply_args_prefixed(factory, tail_indices{}, tup, bhvr); auto fun = apply_moved_args_prefixed(factory, tail_indices{}, tup, bhvr);
receive_impl(rcc, mid, fun); receive_impl(rcc, mid, fun);
} }
......
...@@ -116,28 +116,30 @@ struct make_blocking_behavior_t { ...@@ -116,28 +116,30 @@ struct make_blocking_behavior_t {
// nop // nop
} }
inline blocking_behavior operator()(behavior& x) const { inline blocking_behavior operator()(behavior x) const {
return {std::move(x)}; return {std::move(x)};
} }
template <class F> template <class F>
blocking_behavior_v2<F> operator()(behavior& x, catch_all<F>& y) const { blocking_behavior_v2<F> operator()(behavior x, catch_all<F> y) const {
return {std::move(x), std::move(y)}; return {std::move(x), std::move(y)};
} }
template <class F> template <class F>
blocking_behavior_v3<F> operator()(behavior& x, blocking_behavior_v3<F> operator()(behavior x,
timeout_definition<F>& y) const { timeout_definition<F> y) const {
return {std::move(x), std::move(y)}; return {std::move(x), std::move(y)};
} }
template <class F1, class F2> template <class F1, class F2>
blocking_behavior_v4<F1, F2> operator()(behavior& x, catch_all<F1>& y, blocking_behavior_v4<F1, F2> operator()(behavior x, catch_all<F1> y,
timeout_definition<F2>& z) const { timeout_definition<F2> z) const {
return {std::move(x), std::move(y), std::move(z)}; return {std::move(x), std::move(y), std::move(z)};
} }
}; };
constexpr make_blocking_behavior_t make_blocking_behavior = make_blocking_behavior_t{};
} // namespace detail } // namespace detail
} // namespace caf } // namespace caf
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment