Commit 89cee7a7 authored by Dominik Charousset's avatar Dominik Charousset

Deprecate replies_to and reacts_to

parent 35aea2c1
...@@ -12,6 +12,11 @@ is based on [Keep a Changelog](https://keepachangelog.com). ...@@ -12,6 +12,11 @@ is based on [Keep a Changelog](https://keepachangelog.com).
destructor of the promise now checks for this case. destructor of the promise now checks for this case.
- Accessing URI fields now always returns the normalized string. - Accessing URI fields now always returns the normalized string.
### Deprecated
- The obsolete meta-programming utilities `replies_to` and `reacts_to` no longer
serve any purpose and are thus deprecated.
## [0.18.6] ## [0.18.6]
### Added ### Added
......
...@@ -4,10 +4,8 @@ ...@@ -4,10 +4,8 @@
#pragma once #pragma once
#include "caf/fwd.hpp"
#include "caf/replies_to.hpp"
#include "caf/detail/type_list.hpp" #include "caf/detail/type_list.hpp"
#include "caf/fwd.hpp"
namespace caf { namespace caf {
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#include "caf/detail/type_list.hpp" #include "caf/detail/type_list.hpp"
#include "caf/fwd.hpp" #include "caf/fwd.hpp"
#include "caf/replies_to.hpp"
namespace caf { namespace caf {
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#include "caf/detail/implicit_conversions.hpp" #include "caf/detail/implicit_conversions.hpp"
#include "caf/expected.hpp" #include "caf/expected.hpp"
#include "caf/fwd.hpp" #include "caf/fwd.hpp"
#include "caf/replies_to.hpp"
namespace caf::detail { namespace caf::detail {
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include "caf/delegated.hpp" #include "caf/delegated.hpp"
#include "caf/fwd.hpp" #include "caf/fwd.hpp"
#include "caf/replies_to.hpp"
#include "caf/response_promise.hpp" #include "caf/response_promise.hpp"
#include "caf/system_messages.hpp" #include "caf/system_messages.hpp"
#include "caf/typed_response_promise.hpp" #include "caf/typed_response_promise.hpp"
......
...@@ -4,10 +4,8 @@ ...@@ -4,10 +4,8 @@
#pragma once #pragma once
#include "caf/fwd.hpp"
#include "caf/replies_to.hpp"
#include "caf/detail/type_list.hpp" #include "caf/detail/type_list.hpp"
#include "caf/fwd.hpp"
namespace caf::detail { namespace caf::detail {
......
...@@ -17,12 +17,15 @@ replies_to_type_name(size_t input_size, const std::string* input, ...@@ -17,12 +17,15 @@ replies_to_type_name(size_t input_size, const std::string* input,
size_t output_size, const std::string* output); size_t output_size, const std::string* output);
template <class... Is> template <class... Is>
struct replies_to { struct [[deprecated("write 'result<foo>(bar)' instead of "
"'replies_to<bar>::with<foo>'")]] replies_to {
template <class... Os> template <class... Os>
using with = result<Os...>(Is...); using with = result<Os...>(Is...);
}; };
template <class... Is> template <class... Is>
using reacts_to = result<void>(Is...); using reacts_to
[[deprecated("write 'result<void>(foo)' instead of 'reacts_to<foo>'")]]
= result<void>(Is...);
} // namespace caf } // namespace caf
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include "caf/detail/type_list.hpp" #include "caf/detail/type_list.hpp"
#include "caf/fwd.hpp" #include "caf/fwd.hpp"
#include "caf/replies_to.hpp"
namespace caf { namespace caf {
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include "caf/fwd.hpp" #include "caf/fwd.hpp"
#include "caf/intrusive_ptr.hpp" #include "caf/intrusive_ptr.hpp"
#include "caf/make_actor.hpp" #include "caf/make_actor.hpp"
#include "caf/replies_to.hpp"
#include "caf/stateful_actor.hpp" #include "caf/stateful_actor.hpp"
#include "caf/type_id_list.hpp" #include "caf/type_id_list.hpp"
#include "caf/typed_actor_view_base.hpp" #include "caf/typed_actor_view_base.hpp"
......
...@@ -77,10 +77,10 @@ template <class T> ...@@ -77,10 +77,10 @@ template <class T>
struct is_system_msg_handler : std::false_type {}; struct is_system_msg_handler : std::false_type {};
template <> template <>
struct is_system_msg_handler<reacts_to<exit_msg>> : std::true_type {}; struct is_system_msg_handler<void(exit_msg)> : std::true_type {};
template <> template <>
struct is_system_msg_handler<reacts_to<down_msg>> : std::true_type {}; struct is_system_msg_handler<void(down_msg)> : std::true_type {};
// Tests whether the input list (IList) matches the // Tests whether the input list (IList) matches the
// signature list (SList) for a typed actor behavior // signature list (SList) for a typed actor behavior
......
...@@ -4,15 +4,13 @@ ...@@ -4,15 +4,13 @@
#pragma once #pragma once
#include "caf/replies_to.hpp" #include "caf/actor_system.hpp"
#include "caf/local_actor.hpp" #include "caf/local_actor.hpp"
#include "caf/mixin/behavior_changer.hpp"
#include "caf/mixin/requester.hpp"
#include "caf/scheduled_actor.hpp"
#include "caf/typed_actor.hpp" #include "caf/typed_actor.hpp"
#include "caf/actor_system.hpp"
#include "caf/typed_behavior.hpp" #include "caf/typed_behavior.hpp"
#include "caf/scheduled_actor.hpp"
#include "caf/mixin/requester.hpp"
#include "caf/mixin/behavior_changer.hpp"
namespace caf { namespace caf {
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
// the main distribution directory for license terms and copyright or visit // the main distribution directory for license terms and copyright or visit
// https://github.com/actor-framework/actor-framework/blob/master/LICENSE. // https://github.com/actor-framework/actor-framework/blob/master/LICENSE.
#include "caf/replies_to.hpp"
#include "caf/string_algorithms.hpp" #include "caf/string_algorithms.hpp"
namespace caf { namespace caf {
......
#include "caf/fwd.hpp" #include "caf/fwd.hpp"
#include "caf/result.hpp"
#include "caf/test/bdd_dsl.hpp" #include "caf/test/bdd_dsl.hpp"
#include "caf/type_id.hpp" #include "caf/type_id.hpp"
#include "caf/typed_actor.hpp" #include "caf/typed_actor.hpp"
...@@ -10,13 +11,13 @@ ...@@ -10,13 +11,13 @@
// -- forward declarations for all unit test suites ---------------------------- // -- forward declarations for all unit test suites ----------------------------
using float_actor = caf::typed_actor<caf::reacts_to<float>>; using float_actor = caf::typed_actor<caf::result<void>(float)>;
using int_actor = caf::typed_actor<caf::replies_to<int32_t>::with<int32_t>>; using int_actor = caf::typed_actor<caf::result<int32_t>(int32_t)>;
using foo_actor using foo_actor
= caf::typed_actor<caf::replies_to<int32_t, int32_t, int32_t>::with<int32_t>, = caf::typed_actor<caf::result<int32_t>(int32_t, int32_t, int32_t),
caf::replies_to<double>::with<double, double>>; caf::result<double, double>(double)>;
// A simple POD type. // A simple POD type.
struct dummy_struct { struct dummy_struct {
......
...@@ -23,8 +23,8 @@ behavior testee(event_based_actor* self) { ...@@ -23,8 +23,8 @@ behavior testee(event_based_actor* self) {
}; };
} }
using first_stage = typed_actor<replies_to<int>::with<double, double>>; using first_stage = typed_actor<result<double, double>(int)>;
using second_stage = typed_actor<replies_to<double, double>::with<double>>; using second_stage = typed_actor<result<double>(double, double)>;
first_stage::behavior_type typed_first_stage() { first_stage::behavior_type typed_first_stage() {
return { return {
......
...@@ -367,7 +367,7 @@ CAF_TEST(function_spawn) { ...@@ -367,7 +367,7 @@ CAF_TEST(function_spawn) {
self->send_exit(a2, exit_reason::user_shutdown); self->send_exit(a2, exit_reason::user_shutdown);
} }
using typed_testee = typed_actor<replies_to<abc_atom>::with<std::string>>; using typed_testee = typed_actor<result<std::string>(abc_atom)>;
typed_testee::behavior_type testee() { typed_testee::behavior_type testee() {
return {[](abc_atom) { return {[](abc_atom) {
......
...@@ -15,7 +15,7 @@ using namespace caf; ...@@ -15,7 +15,7 @@ using namespace caf;
namespace { namespace {
using calculator = typed_actor<replies_to<int, int>::with<int>>; using calculator = typed_actor<result<int>(int, int)>;
calculator::behavior_type adder() { calculator::behavior_type adder() {
return { return {
...@@ -39,7 +39,7 @@ calculator::behavior_type divider() { ...@@ -39,7 +39,7 @@ calculator::behavior_type divider() {
}; };
} }
using doubler = typed_actor<replies_to<int>::with<int, int>>; using doubler = typed_actor<result<int, int>(int)>;
doubler::behavior_type simple_doubler() { doubler::behavior_type simple_doubler() {
return { return {
...@@ -49,8 +49,7 @@ doubler::behavior_type simple_doubler() { ...@@ -49,8 +49,7 @@ doubler::behavior_type simple_doubler() {
}; };
} }
using cell using cell = typed_actor<result<void>(put_atom, int), result<int>(get_atom)>;
= typed_actor<reacts_to<put_atom, int>, replies_to<get_atom>::with<int>>;
struct cell_state { struct cell_state {
int value = 0; int value = 0;
......
...@@ -17,8 +17,8 @@ using namespace caf; ...@@ -17,8 +17,8 @@ using namespace caf;
namespace { namespace {
// Simple int32_terface for testee actors. // Simple int32 interface for testee actors.
using testee_actor = typed_actor<replies_to<int32_t>::with<int32_t>>; using testee_actor = typed_actor<result<int32_t>(int32_t)>;
// Dynamically typed testee. // Dynamically typed testee.
behavior dt_testee() { behavior dt_testee() {
......
...@@ -143,8 +143,7 @@ ostream& operator<<(ostream& out, const pair<bool, int>& x) { ...@@ -143,8 +143,7 @@ ostream& operator<<(ostream& out, const pair<bool, int>& x) {
} // namespace std } // namespace std
CAF_TEST(typed_behavior_assignment) { CAF_TEST(typed_behavior_assignment) {
using bh1 = typed_beh<replies_to<int>::with<double>, using bh1 = typed_beh<result<double>(int), result<int, int>(double, double)>;
replies_to<double, double>::with<int, int>>;
// compatible handlers resulting in perfect match // compatible handlers resulting in perfect match
auto f1 = [=](int) { return 0.; }; auto f1 = [=](int) { return 0.; };
auto f2 = [=](double, double) -> result<int, int> { return {0, 0}; }; auto f2 = [=](double, double) -> result<int, int> { return {0, 0}; };
...@@ -171,14 +170,16 @@ CAF_TEST(typed_behavior_assignment) { ...@@ -171,14 +170,16 @@ CAF_TEST(typed_behavior_assignment) {
CHECK_EQ(bi_pair(false, 0), tb_assign<bh1>(e2, f2)); CHECK_EQ(bi_pair(false, 0), tb_assign<bh1>(e2, f2));
CHECK_EQ(bi_pair(false, 0), tb_assign<bh1>(e2, e1)); CHECK_EQ(bi_pair(false, 0), tb_assign<bh1>(e2, e1));
using bh2 using bh2
= typed_beh<reacts_to<int>, reacts_to<int, int>, reacts_to<int, int, int>, = typed_beh<result<void>(int), //
reacts_to<int, int, int, int>, result<void>(int, int), //
reacts_to<int, int, int, int, int>, result<void>(int, int, int), //
reacts_to<int, int, int, int, int, int>, result<void>(int, int, int, int),
reacts_to<int, int, int, int, int, int, int>, result<void>(int, int, int, int, int),
reacts_to<int, int, int, int, int, int, int, int>, result<void>(int, int, int, int, int, int),
reacts_to<int, int, int, int, int, int, int, int, int>, result<void>(int, int, int, int, int, int, int),
reacts_to<int, int, int, int, int, int, int, int, int, int>>; result<void>(int, int, int, int, int, int, int, int),
result<void>(int, int, int, int, int, int, int, int, int),
result<void>(int, int, int, int, int, int, int, int, int, int)>;
auto h0 = [](int) {}; auto h0 = [](int) {};
auto h1 = [](int, int) {}; auto h1 = [](int, int) {};
auto h2 = [](int, int, int) {}; auto h2 = [](int, int, int) {};
......
...@@ -12,29 +12,23 @@ ...@@ -12,29 +12,23 @@
#include "caf/event_based_actor.hpp" #include "caf/event_based_actor.hpp"
#include "caf/policy/select_all.hpp" #include "caf/policy/select_all.hpp"
#include "caf/result.hpp"
using namespace caf; using namespace caf;
namespace { namespace {
using discarding_server_type = typed_actor<replies_to<int, int>::with<void>>; using discarding_server_type = typed_actor<result<void>(int, int)>;
using adding_server_type = typed_actor<replies_to<int, int>::with<int>>; using adding_server_type = typed_actor<result<int>(int, int)>;
using result_type = variant<none_t, unit_t, int>; using result_type = variant<none_t, unit_t, int>;
struct fixture : test_coordinator_fixture<> { struct fixture : test_coordinator_fixture<> {
fixture() {
result = std::make_shared<result_type>(none);
discarding_server = make_server([](int, int) {});
adding_server = make_server([](int x, int y) { return x + y; });
run();
}
template <class F> template <class F>
auto make_server(F f) auto make_server(F f) {
-> typed_actor<replies_to<int, int>::with<decltype(f(1, 2))>> { using res_t = caf::result<decltype(f(1, 2))>;
using impl = typed_actor<replies_to<int, int>::with<decltype(f(1, 2))>>; using impl = typed_actor<res_t(int, int)>;
auto init = [f]() -> typename impl::behavior_type { auto init = [f]() -> typename impl::behavior_type {
return { return {
[f](int x, int y) { return f(x, y); }, [f](int x, int y) { return f(x, y); },
...@@ -43,6 +37,13 @@ struct fixture : test_coordinator_fixture<> { ...@@ -43,6 +37,13 @@ struct fixture : test_coordinator_fixture<> {
return sys.spawn(init); return sys.spawn(init);
} }
fixture() {
result = std::make_shared<result_type>(none);
discarding_server = make_server([](int, int) {});
adding_server = make_server([](int x, int y) { return x + y; });
run();
}
template <class T> template <class T>
T make_delegator(T dest) { T make_delegator(T dest) {
auto f = [=](typename T::pointer self) -> typename T::behavior_type { auto f = [=](typename T::pointer self) -> typename T::behavior_type {
......
...@@ -19,7 +19,7 @@ namespace { ...@@ -19,7 +19,7 @@ namespace {
using ms = std::chrono::milliseconds; using ms = std::chrono::milliseconds;
using timer = typed_actor<reacts_to<reset_atom>>; using timer = typed_actor<result<void>(reset_atom)>;
struct timer_state { struct timer_state {
bool had_reset = false; bool had_reset = false;
......
...@@ -16,9 +16,8 @@ ...@@ -16,9 +16,8 @@
using namespace caf; using namespace caf;
CAF_TEST(make_typed_behavior automatically deduces its types) { CAF_TEST(make_typed_behavior automatically deduces its types) {
using handle using handle = typed_actor<result<void>(std::string),
= typed_actor<reacts_to<std::string>, replies_to<int32_t>::with<int32_t>, result<int32_t>(int32_t), result<double>(double)>;
replies_to<double>::with<double>>;
auto bhvr = make_typed_behavior([](const std::string&) {}, auto bhvr = make_typed_behavior([](const std::string&) {},
[](int32_t x) { return x; }, [](int32_t x) { return x; },
[](double x) { return x; }); [](double x) { return x; });
......
...@@ -24,11 +24,6 @@ using namespace std::string_literals; ...@@ -24,11 +24,6 @@ using namespace std::string_literals;
namespace { namespace {
static_assert(std::is_same<reacts_to<int, int>, result<void>(int, int)>::value);
static_assert(std::is_same<replies_to<double>::with<double>,
result<double>(double)>::value);
// check invariants of type system // check invariants of type system
using dummy1 = typed_actor<result<void>(int, int), result<double>(double)>; using dummy1 = typed_actor<result<void>(int, int), result<double>(double)>;
...@@ -38,7 +33,7 @@ static_assert(std::is_convertible<dummy2, dummy1>::value, ...@@ -38,7 +33,7 @@ static_assert(std::is_convertible<dummy2, dummy1>::value,
"handle not assignable to narrower definition"); "handle not assignable to narrower definition");
using dummy3 = typed_actor<reacts_to<float, int>>; using dummy3 = typed_actor<reacts_to<float, int>>;
using dummy4 = typed_actor<replies_to<int>::with<double>>; using dummy4 = typed_actor<result<double>(int)>;
using dummy5 = dummy4::extend_with<dummy3>; using dummy5 = dummy4::extend_with<dummy3>;
static_assert(std::is_convertible<dummy5, dummy3>::value, static_assert(std::is_convertible<dummy5, dummy3>::value,
...@@ -51,7 +46,7 @@ static_assert(std::is_convertible<dummy5, dummy4>::value, ...@@ -51,7 +46,7 @@ static_assert(std::is_convertible<dummy5, dummy4>::value,
* simple request/response test * * simple request/response test *
******************************************************************************/ ******************************************************************************/
using server_type = typed_actor<replies_to<my_request>::with<bool>>; using server_type = typed_actor<result<bool>(my_request)>;
server_type::behavior_type typed_server1() { server_type::behavior_type typed_server1() {
return { return {
...@@ -91,9 +86,8 @@ void client(event_based_actor* self, const actor& parent, ...@@ -91,9 +86,8 @@ void client(event_based_actor* self, const actor& parent,
******************************************************************************/ ******************************************************************************/
using event_testee_type using event_testee_type
= typed_actor<replies_to<get_state_atom>::with<string>, = typed_actor<result<string>(get_state_atom), result<void>(string),
replies_to<string>::with<void>, replies_to<float>::with<void>, result<void>(float), result<int>(int)>;
replies_to<int>::with<int>>;
class event_testee : public event_testee_type::base { class event_testee : public event_testee_type::base {
public: public:
...@@ -137,7 +131,7 @@ public: ...@@ -137,7 +131,7 @@ public:
* simple 'forwarding' chain * * simple 'forwarding' chain *
******************************************************************************/ ******************************************************************************/
using string_actor = typed_actor<replies_to<string>::with<string>>; using string_actor = typed_actor<result<string>(string)>;
string_actor::behavior_type string_reverter() { string_actor::behavior_type string_reverter() {
return { return {
...@@ -160,8 +154,7 @@ string_actor::behavior_type string_delegator(string_actor::pointer self, ...@@ -160,8 +154,7 @@ string_actor::behavior_type string_delegator(string_actor::pointer self,
}; };
} }
using maybe_string_actor using maybe_string_actor = typed_actor<result<ok_atom, string>(string)>;
= typed_actor<replies_to<string>::with<ok_atom, string>>;
maybe_string_actor::behavior_type maybe_string_reverter() { maybe_string_actor::behavior_type maybe_string_reverter() {
return { return {
...@@ -285,7 +278,7 @@ CAF_TEST(typed_spawns) { ...@@ -285,7 +278,7 @@ CAF_TEST(typed_spawns) {
CAF_TEST(event_testee_series) { CAF_TEST(event_testee_series) {
auto et = self->spawn<event_testee>(); auto et = self->spawn<event_testee>();
MESSAGE("et->message_types() returns an interface description"); MESSAGE("et->message_types() returns an interface description");
typed_actor<replies_to<get_state_atom>::with<string>> sub_et = et; typed_actor<result<string>(get_state_atom)> sub_et = et;
std::set<string> iface{"(get_state_atom) -> (std::string)", std::set<string> iface{"(get_state_atom) -> (std::string)",
"(std::string) -> (void)", "(float) -> (void)", "(std::string) -> (void)", "(float) -> (void)",
"(int32_t) -> (int32_t)"}; "(int32_t) -> (int32_t)"};
...@@ -350,7 +343,7 @@ CAF_TEST(sending_typed_actors_and_down_msg) { ...@@ -350,7 +343,7 @@ CAF_TEST(sending_typed_actors_and_down_msg) {
} }
CAF_TEST(check_signature) { CAF_TEST(check_signature) {
using foo_type = typed_actor<replies_to<put_atom>::with<ok_atom>>; using foo_type = typed_actor<result<ok_atom>(put_atom)>;
using foo_result_type = result<ok_atom>; using foo_result_type = result<ok_atom>;
using bar_type = typed_actor<reacts_to<ok_atom>>; using bar_type = typed_actor<reacts_to<ok_atom>>;
auto foo_action = [](foo_type::pointer ptr) -> foo_type::behavior_type { auto foo_action = [](foo_type::pointer ptr) -> foo_type::behavior_type {
......
...@@ -71,25 +71,25 @@ namespace caf::io { ...@@ -71,25 +71,25 @@ namespace caf::io {
/// ///
/// } /// }
/// ~~~ /// ~~~
using middleman_actor = typed_actor< using middleman_actor = typed_actor< //
replies_to<publish_atom, uint16_t, strong_actor_ptr, std::set<std::string>, result<uint16_t>(publish_atom, uint16_t, strong_actor_ptr,
std::string, bool>::with<uint16_t>, std::set<std::string>, std::string, bool),
replies_to<open_atom, uint16_t, std::string, bool>::with<uint16_t>, result<uint16_t>(open_atom, uint16_t, std::string, bool),
replies_to<connect_atom, std::string, result<node_id, strong_actor_ptr, std::set<std::string>>(
uint16_t>::with<node_id, strong_actor_ptr, std::set<std::string>>, connect_atom, std::string, uint16_t),
reacts_to<unpublish_atom, actor_addr, uint16_t>, result<void>(unpublish_atom, actor_addr, uint16_t),
reacts_to<close_atom, uint16_t>, result<void>(close_atom, uint16_t),
replies_to<spawn_atom, node_id, std::string, message, result<strong_actor_ptr>(spawn_atom, node_id, std::string, message,
std::set<std::string>>::with<strong_actor_ptr>, std::set<std::string>),
replies_to<get_atom, group_atom, node_id, std::string>::with<actor>, result<actor>(get_atom, group_atom, node_id, std::string),
replies_to<get_atom, node_id>::with<node_id, std::string, uint16_t>>; result<node_id, std::string, uint16_t>(get_atom, node_id)>;
/// Spawns the default implementation for the `middleman_actor` interface. /// Spawns the default implementation for the `middleman_actor` interface.
CAF_IO_EXPORT middleman_actor make_middleman_actor(actor_system& sys, actor db); CAF_IO_EXPORT middleman_actor make_middleman_actor(actor_system& sys, actor db);
......
...@@ -41,16 +41,16 @@ namespace io { ...@@ -41,16 +41,16 @@ namespace io {
/// Denotes a minimal "client" broker managing one or more connection /// Denotes a minimal "client" broker managing one or more connection
/// handles by reacting to `new_data_msg` and `connection_closed_msg`. /// handles by reacting to `new_data_msg` and `connection_closed_msg`.
/// @relates typed_broker /// @relates typed_broker
using connection_handler = typed_actor<reacts_to<new_data_msg>, using connection_handler = typed_actor<result<void>(new_data_msg),
reacts_to<connection_closed_msg>>; result<void>(connection_closed_msg)>;
/// Denotes a minimal "server" broker managing one or more accept /// Denotes a minimal "server" broker managing one or more accept
/// handles by reacting to `new_connection_msg` and `acceptor_closed_msg`. /// handles by reacting to `new_connection_msg` and `acceptor_closed_msg`.
/// The accept handler usually calls `self->fork(...)` when receiving /// The accept handler usually calls `self->fork(...)` when receiving
/// a `new_connection_msg`. /// a `new_connection_msg`.
/// @relates typed_broker /// @relates typed_broker
using accept_handler = typed_actor<reacts_to<new_connection_msg>, using accept_handler = typed_actor<result<void>(new_connection_msg),
reacts_to<acceptor_closed_msg>>; result<void>(acceptor_closed_msg)>;
/// A typed broker mediates between actor systems and other /// A typed broker mediates between actor systems and other
/// components in the network. /// components in the network.
......
#include "caf/test/bdd_dsl.hpp" #include "caf/test/bdd_dsl.hpp"
#include "caf/test/io_dsl.hpp" #include "caf/test/io_dsl.hpp"
using calculator = caf::typed_actor< using calculator
caf::replies_to<caf::add_atom, int32_t, int32_t>::with<int32_t>, = caf::typed_actor<caf::result<int32_t>(caf::add_atom, int32_t, int32_t),
caf::replies_to<caf::sub_atom, int32_t, int32_t>::with<int32_t>>; caf::result<int32_t>(caf::sub_atom, int32_t, int32_t)>;
CAF_BEGIN_TYPE_ID_BLOCK(io_test, caf::first_custom_type_id) CAF_BEGIN_TYPE_ID_BLOCK(io_test, caf::first_custom_type_id)
......
...@@ -121,7 +121,7 @@ behavior peer_acceptor_fun(broker* self, const actor& buddy) { ...@@ -121,7 +121,7 @@ behavior peer_acceptor_fun(broker* self, const actor& buddy) {
}; };
} }
using int_peer = connection_handler::extend<replies_to<int>::with<int>>; using int_peer = connection_handler::extend<result<int>(int)>;
int_peer::behavior_type int_peer_fun(int_peer::broker_pointer) { int_peer::behavior_type int_peer_fun(int_peer::broker_pointer) {
return { return {
......
...@@ -58,7 +58,7 @@ behavior pong(event_based_actor* self, suite_state_ptr ssp) { ...@@ -58,7 +58,7 @@ behavior pong(event_based_actor* self, suite_state_ptr ssp) {
}; };
} }
using fragile_mirror_actor = typed_actor<replies_to<int>::with<int>>; using fragile_mirror_actor = typed_actor<result<int>(int)>;
fragile_mirror_actor::behavior_type fragile_mirror_actor::behavior_type
fragile_mirror(fragile_mirror_actor::pointer self) { fragile_mirror(fragile_mirror_actor::pointer self) {
......
...@@ -240,13 +240,14 @@ Statically typed actors require abstract messaging interfaces to allow the ...@@ -240,13 +240,14 @@ Statically typed actors require abstract messaging interfaces to allow the
compiler to type-check actor communication. Interfaces in CAF are defined using compiler to type-check actor communication. Interfaces in CAF are defined using
the variadic template ``typed_actor<...>``, which defines the proper the variadic template ``typed_actor<...>``, which defines the proper
actor handle at the same time. Each template parameter defines one actor handle at the same time. Each template parameter defines one
``input/output`` pair via ``input/output`` pair via function signature syntax with the return type wrapped
``replies_to<X1,...,Xn>::with<Y1,...,Yn>``. For inputs that do not in a ``result``. For example, ``typed_actor<result<string, string>(double)>``.
generate outputs, ``reacts_to<X1,...,Xn>`` can be used as shortcut for Also, the arguments must not use any cv-qualifiers.
``replies_to<X1,...,Xn>::with<void>``. In the same way functions cannot
be overloaded only by their return type, interfaces cannot accept one input In the same way functions cannot be overloaded only by their return type,
twice (possibly mapping it to different outputs). The example below defines a interfaces cannot accept one input twice (possibly mapping it to different
messaging interface for a simple calculator. outputs). The example below defines a messaging interface for a simple
calculator.
.. literalinclude:: /examples/message_passing/calculator.cpp .. literalinclude:: /examples/message_passing/calculator.cpp
:language: C++ :language: C++
......
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