Commit 09da4942 authored by Dominik Charousset's avatar Dominik Charousset

Integrate review feedback

parent 50bedc96
...@@ -116,13 +116,8 @@ public: ...@@ -116,13 +116,8 @@ public:
template <template <class> class MergePolicy, template <template <class> class MergePolicy,
message_priority Prio = message_priority::normal, class Container, message_priority Prio = message_priority::normal, class Container,
class... Ts> class... Ts>
// TODO: replace this monstrosity with 'auto' when switching to C++17 auto fan_out_request(const Container& destinations, const duration& timeout,
response_handle<Subtype, Ts&&... xs) {
MergePolicy<response_type_t<
typename Container::value_type::signatures,
detail::implicit_conversions_t<detail::decay_t<Ts>>...>>>
fan_out_request(const Container& destinations, const duration& timeout,
Ts&&... xs) {
using handle_type = typename Container::value_type; using handle_type = typename Container::value_type;
using namespace detail; using namespace detail;
static_assert(sizeof...(Ts) > 0, "no message to send"); static_assert(sizeof...(Ts) > 0, "no message to send");
...@@ -159,13 +154,8 @@ public: ...@@ -159,13 +154,8 @@ public:
template <template <class> class MergePolicy, template <template <class> class MergePolicy,
message_priority Prio = message_priority::normal, class Rep, message_priority Prio = message_priority::normal, class Rep,
class Period, class Container, class... Ts> class Period, class Container, class... Ts>
// TODO: replace this monstrosity with 'auto' when switching to C++17 auto fan_out_request(const Container& destinations,
response_handle<Subtype, std::chrono::duration<Rep, Period> timeout, Ts&&... xs) {
MergePolicy<response_type_t<
typename Container::value_type::signatures,
detail::implicit_conversions_t<detail::decay_t<Ts>>...>>>
fan_out_request(const Container& destinations,
std::chrono::duration<Rep, Period> timeout, Ts&&... xs) {
return request<MergePolicy, Prio>(destinations, duration{timeout}, return request<MergePolicy, Prio>(destinations, duration{timeout},
std::forward<Ts>(xs)...); std::forward<Ts>(xs)...);
} }
......
...@@ -57,8 +57,7 @@ struct fan_in_responses_helper { ...@@ -57,8 +57,7 @@ struct fan_in_responses_helper {
results.reserve(pending); results.reserve(pending);
} }
// TODO: return 'auto' from this function when switching to C++17 auto wrap() {
std::function<void(T&)> wrap() {
return [this](T& x) { (*this)(x); }; return [this](T& x) { (*this)(x); };
} }
}; };
...@@ -85,8 +84,7 @@ struct fan_in_responses_tuple_helper { ...@@ -85,8 +84,7 @@ struct fan_in_responses_tuple_helper {
results.reserve(pending); results.reserve(pending);
} }
// TODO: return 'auto' from this function when switching to C++17 auto wrap() {
std::function<void(Ts&...)> wrap() {
return [this](Ts&... xs) { (*this)(xs...); }; return [this](Ts&... xs) { (*this)(xs...); };
} }
}; };
......
...@@ -73,9 +73,8 @@ public: ...@@ -73,9 +73,8 @@ public:
void await(F f, OnError g) const { void await(F f, OnError g) const {
static_assert(detail::is_callable<F>::value, "F must provide a single, " static_assert(detail::is_callable<F>::value, "F must provide a single, "
"non-template operator()"); "non-template operator()");
static_assert(detail::is_callable<F>::value, static_assert(detail::is_callable_with<OnError, error&>::value,
"OnError must provide a single, non-template operator() " "OnError must provide an operator() that takes a caf::error");
"that takes a caf::error");
using result_type = typename detail::get_callable_trait<F>::result_type; using result_type = typename detail::get_callable_trait<F>::result_type;
static_assert(std::is_same<void, result_type>::value, static_assert(std::is_same<void, result_type>::value,
"response handlers are not allowed to have a return " "response handlers are not allowed to have a return "
...@@ -96,9 +95,8 @@ public: ...@@ -96,9 +95,8 @@ public:
void then(F f, OnError g) const { void then(F f, OnError g) const {
static_assert(detail::is_callable<F>::value, "F must provide a single, " static_assert(detail::is_callable<F>::value, "F must provide a single, "
"non-template operator()"); "non-template operator()");
static_assert(detail::is_callable<F>::value, static_assert(detail::is_callable_with<OnError, error&>::value,
"OnError must provide a single, non-template operator() " "OnError must provide an operator() that takes a caf::error");
"that takes a caf::error");
using result_type = typename detail::get_callable_trait<F>::result_type; using result_type = typename detail::get_callable_trait<F>::result_type;
static_assert(std::is_same<void, result_type>::value, static_assert(std::is_same<void, result_type>::value,
"response handlers are not allowed to have a return " "response handlers are not allowed to have a return "
...@@ -121,9 +119,8 @@ public: ...@@ -121,9 +119,8 @@ public:
detail::is_handler_for_ef<OnError, error> receive(F f, OnError g) { detail::is_handler_for_ef<OnError, error> receive(F f, OnError g) {
static_assert(detail::is_callable<F>::value, "F must provide a single, " static_assert(detail::is_callable<F>::value, "F must provide a single, "
"non-template operator()"); "non-template operator()");
static_assert(detail::is_callable<F>::value, static_assert(detail::is_callable_with<OnError, error&>::value,
"OnError must provide a single, non-template operator() " "OnError must provide an operator() that takes a caf::error");
"that takes a caf::error");
using result_type = typename detail::get_callable_trait<F>::result_type; using result_type = typename detail::get_callable_trait<F>::result_type;
static_assert(std::is_same<void, result_type>::value, static_assert(std::is_same<void, result_type>::value,
"response handlers are not allowed to have a return " "response handlers are not allowed to have a return "
......
...@@ -154,9 +154,9 @@ CAF_TEST(delegated request with integer result) { ...@@ -154,9 +154,9 @@ CAF_TEST(delegated request with integer result) {
CAF_TEST(requesters support fan_out_request) { CAF_TEST(requesters support fan_out_request) {
using policy::fan_in_responses; using policy::fan_in_responses;
std::vector<adding_server_type> workers{ std::vector<adding_server_type> workers{
adding_server = make_server([](int x, int y) { return x + y; }), make_server([](int x, int y) { return x + y; }),
adding_server = make_server([](int x, int y) { return x + y; }), make_server([](int x, int y) { return x + y; }),
adding_server = make_server([](int x, int y) { return x + y; }), make_server([](int x, int y) { return x + y; }),
}; };
run(); run();
auto sum = std::make_shared<int>(0); auto sum = std::make_shared<int>(0);
......
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