Commit 269acb49 authored by Dominik Charousset's avatar Dominik Charousset

Move typed_broker out of experimental namespace

parent 28747e3f
...@@ -32,12 +32,10 @@ template <class... Sigs> ...@@ -32,12 +32,10 @@ template <class... Sigs>
class typed_event_based_actor; class typed_event_based_actor;
namespace io { namespace io {
namespace experimental {
template <class... Sigs> template <class... Sigs>
class typed_broker; class typed_broker;
} // namespace experimental
} // namespace io } // namespace io
enum class spawn_mode { enum class spawn_mode {
...@@ -117,10 +115,10 @@ struct infer_handle_from_fun_impl<Result, ...@@ -117,10 +115,10 @@ struct infer_handle_from_fun_impl<Result,
// statically typed broker with self pointer // statically typed broker with self pointer
template <class Result, class... Sigs> template <class Result, class... Sigs>
struct infer_handle_from_fun_impl<Result, struct infer_handle_from_fun_impl<Result,
io::experimental::typed_broker<Sigs...>*, io::typed_broker<Sigs...>*,
true> { true> {
using type = typed_actor<Sigs...>; using type = typed_actor<Sigs...>;
using impl = io::experimental::typed_broker<Sigs...>; using impl = io::typed_broker<Sigs...>;
using behavior_type = typed_behavior<Sigs...>; using behavior_type = typed_behavior<Sigs...>;
static constexpr spawn_mode mode = spawn_mode::function_with_selfptr; static constexpr spawn_mode mode = spawn_mode::function_with_selfptr;
}; };
...@@ -130,14 +128,14 @@ template <class Result, class State, class... Sigs> ...@@ -130,14 +128,14 @@ template <class Result, class State, class... Sigs>
struct infer_handle_from_fun_impl<Result, struct infer_handle_from_fun_impl<Result,
stateful_actor< stateful_actor<
State, State,
io::experimental::typed_broker<Sigs...> io::typed_broker<Sigs...>
>*, >*,
true> { true> {
using type = typed_actor<Sigs...>; using type = typed_actor<Sigs...>;
using impl = using impl =
stateful_actor< stateful_actor<
State, State,
io::experimental::typed_broker<Sigs...> io::typed_broker<Sigs...>
>; >;
using behavior_type = typed_behavior<Sigs...>; using behavior_type = typed_behavior<Sigs...>;
static constexpr spawn_mode mode = spawn_mode::function_with_selfptr; static constexpr spawn_mode mode = spawn_mode::function_with_selfptr;
...@@ -214,4 +212,3 @@ using infer_handle_from_state_t = typename infer_handle_from_state<T>::type; ...@@ -214,4 +212,3 @@ using infer_handle_from_state_t = typename infer_handle_from_state<T>::type;
} // namespace caf } // namespace caf
#endif // CAF_INFER_HANDLE_HPP #endif // CAF_INFER_HANDLE_HPP
...@@ -44,12 +44,10 @@ template <class... Sigs> ...@@ -44,12 +44,10 @@ template <class... Sigs>
class typed_event_based_actor; class typed_event_based_actor;
namespace io { namespace io {
namespace experimental {
template <class... Sigs> template <class... Sigs>
class typed_broker; class typed_broker;
} // namespace experimental
} // namespace io } // namespace io
/// Identifies a statically typed actor. /// Identifies a statically typed actor.
...@@ -96,10 +94,10 @@ class typed_actor : detail::comparable<typed_actor<Sigs...>>, ...@@ -96,10 +94,10 @@ class typed_actor : detail::comparable<typed_actor<Sigs...>>,
using base = typed_event_based_actor<Sigs...>; using base = typed_event_based_actor<Sigs...>;
/// Identifies pointers to brokers implementing this interface. /// Identifies pointers to brokers implementing this interface.
using broker_pointer = io::experimental::typed_broker<Sigs...>*; using broker_pointer = io::typed_broker<Sigs...>*;
/// Identifies the base class of brokers implementing this interface. /// Identifies the base class of brokers implementing this interface.
using broker_base = io::experimental::typed_broker<Sigs...>; using broker_base = io::typed_broker<Sigs...>;
/// Stores the template parameter pack. /// Stores the template parameter pack.
using signatures = detail::type_list<Sigs...>; using signatures = detail::type_list<Sigs...>;
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "caf/io/broker.hpp" #include "caf/io/broker.hpp"
#include "caf/io/middleman.hpp" #include "caf/io/middleman.hpp"
#include "caf/io/basp_broker.hpp" #include "caf/io/basp_broker.hpp"
#include "caf/io/typed_broker.hpp"
#include "caf/io/receive_policy.hpp" #include "caf/io/receive_policy.hpp"
#include "caf/io/middleman_actor.hpp" #include "caf/io/middleman_actor.hpp"
#include "caf/io/system_messages.hpp" #include "caf/io/system_messages.hpp"
......
...@@ -17,8 +17,8 @@ ...@@ -17,8 +17,8 @@
* http://www.boost.org/LICENSE_1_0.txt. * * http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/ ******************************************************************************/
#ifndef CAF_IO_EXPERIMENTAL_TYPED_BROKER_HPP #ifndef CAF_IO_TYPED_BROKER_HPP
#define CAF_IO_EXPERIMENTAL_TYPED_BROKER_HPP #define CAF_IO_TYPED_BROKER_HPP
#include <map> #include <map>
#include <vector> #include <vector>
...@@ -41,20 +41,26 @@ ...@@ -41,20 +41,26 @@
namespace caf { namespace caf {
namespace io { namespace io {
namespace experimental {
using minimal_client = typed_actor<reacts_to<new_data_msg>,
reacts_to<connection_closed_msg>>;
using minimal_server =
minimal_client::extend<reacts_to<new_connection_msg>,
reacts_to<acceptor_closed_msg>>;
template <class... Sigs> template <class... Sigs>
class typed_broker; class typed_broker;
/// A typed broker mediates between actor systems and other components in /// Denotes a minimal "client" broker managing one or more connection
/// the network. /// handles by reacting to `new_data_msg` and `connection_closed_msg`.
/// @relates typed_broker
using connection_handler = typed_actor<reacts_to<new_data_msg>,
reacts_to<connection_closed_msg>>;
/// Denotes a minimal "server" broker managing one or more accept
/// handles by reacting to `new_connection_msg` and `acceptor_closed_msg`.
/// The accept handler usually calls `self->fork(...)` when receiving
/// a `new_connection_msg`.
/// @relates typed_broker
using accept_handler = typed_actor<reacts_to<new_connection_msg>,
reacts_to<acceptor_closed_msg>>;
/// A typed broker mediates between actor systems and other
/// components in the network.
/// @extends local_actor /// @extends local_actor
template <class... Sigs> template <class... Sigs>
class typed_broker : public abstract_event_based_actor<typed_behavior<Sigs...>, class typed_broker : public abstract_event_based_actor<typed_behavior<Sigs...>,
...@@ -72,11 +78,11 @@ public: ...@@ -72,11 +78,11 @@ public:
using super::send; using super::send;
using super::delayed_send; using super::delayed_send;
template <class... DestSigs, class... Ts> template <class... Dest, class... Ts>
void send(message_priority mp, const typed_actor<DestSigs...>& dest, Ts&&... xs) { void send(message_priority mp, const typed_actor<Dest...>& dest, Ts&&... xs) {
detail::sender_signature_checker< detail::sender_signature_checker<
detail::type_list<Sigs...>, detail::type_list<Sigs...>,
detail::type_list<DestSigs...>, detail::type_list<Dest...>,
detail::type_list< detail::type_list<
typename detail::implicit_conversions< typename detail::implicit_conversions<
typename std::decay<Ts>::type typename std::decay<Ts>::type
...@@ -86,11 +92,11 @@ public: ...@@ -86,11 +92,11 @@ public:
super::send(mp, dest, std::forward<Ts>(xs)...); super::send(mp, dest, std::forward<Ts>(xs)...);
} }
template <class... DestSigs, class... Ts> template <class... Dest, class... Ts>
void send(const typed_actor<DestSigs...>& dest, Ts&&... xs) { void send(const typed_actor<Dest...>& dest, Ts&&... xs) {
detail::sender_signature_checker< detail::sender_signature_checker<
detail::type_list<Sigs...>, detail::type_list<Sigs...>,
detail::type_list<DestSigs...>, detail::type_list<Dest...>,
detail::type_list< detail::type_list<
typename detail::implicit_conversions< typename detail::implicit_conversions<
typename std::decay<Ts>::type typename std::decay<Ts>::type
...@@ -100,12 +106,12 @@ public: ...@@ -100,12 +106,12 @@ public:
super::send(dest, std::forward<Ts>(xs)...); super::send(dest, std::forward<Ts>(xs)...);
} }
template <class... DestSigs, class... Ts> template <class... Dest, class... Ts>
void delayed_send(message_priority mp, const typed_actor<DestSigs...>& dest, void delayed_send(message_priority mp, const typed_actor<Dest...>& dest,
const duration& rtime, Ts&&... xs) { const duration& rtime, Ts&&... xs) {
detail::sender_signature_checker< detail::sender_signature_checker<
detail::type_list<Sigs...>, detail::type_list<Sigs...>,
detail::type_list<DestSigs...>, detail::type_list<Dest...>,
detail::type_list< detail::type_list<
typename detail::implicit_conversions< typename detail::implicit_conversions<
typename std::decay<Ts>::type typename std::decay<Ts>::type
...@@ -115,12 +121,12 @@ public: ...@@ -115,12 +121,12 @@ public:
super::delayed_send(mp, dest, rtime, std::forward<Ts>(xs)...); super::delayed_send(mp, dest, rtime, std::forward<Ts>(xs)...);
} }
template <class... DestSigs, class... Ts> template <class... Dest, class... Ts>
void delayed_send(const typed_actor<DestSigs...>& dest, void delayed_send(const typed_actor<Dest...>& dest,
const duration& rtime, Ts&&... xs) { const duration& rtime, Ts&&... xs) {
detail::sender_signature_checker< detail::sender_signature_checker<
detail::type_list<Sigs...>, detail::type_list<Sigs...>,
detail::type_list<DestSigs...>, detail::type_list<Dest...>,
detail::type_list< detail::type_list<
typename detail::implicit_conversions< typename detail::implicit_conversions<
typename std::decay<Ts>::type typename std::decay<Ts>::type
...@@ -158,7 +164,7 @@ public: ...@@ -158,7 +164,7 @@ public:
using impl = typename infer_handle_from_fun<F>::impl; using impl = typename infer_handle_from_fun<F>::impl;
static_assert(std::is_convertible< static_assert(std::is_convertible<
typename impl::actor_hdl, typename impl::actor_hdl,
minimal_client connection_handler
>::value, >::value,
"Cannot fork: new broker misses required handlers"); "Cannot fork: new broker misses required handlers");
actor_config cfg{this->context()}; actor_config cfg{this->context()};
...@@ -173,13 +179,13 @@ public: ...@@ -173,13 +179,13 @@ public:
} }
connection_handle add_tcp_scribe(const std::string& host, uint16_t port) { connection_handle add_tcp_scribe(const std::string& host, uint16_t port) {
static_assert(std::is_convertible<actor_hdl, minimal_client>::value, static_assert(std::is_convertible<actor_hdl, connection_handler>::value,
"Cannot add scribe: broker misses required handlers"); "Cannot add scribe: broker misses required handlers");
return super::add_tcp_scribe(host, port); return super::add_tcp_scribe(host, port);
} }
connection_handle add_tcp_scribe(network::native_socket fd) { connection_handle add_tcp_scribe(network::native_socket fd) {
static_assert(std::is_convertible<actor_hdl, minimal_client>::value, static_assert(std::is_convertible<actor_hdl, connection_handler>::value,
"Cannot add scribe: broker misses required handlers"); "Cannot add scribe: broker misses required handlers");
return super::add_tcp_scribe(fd); return super::add_tcp_scribe(fd);
} }
...@@ -188,13 +194,13 @@ public: ...@@ -188,13 +194,13 @@ public:
add_tcp_doorman(uint16_t port = 0, add_tcp_doorman(uint16_t port = 0,
const char* in = nullptr, const char* in = nullptr,
bool reuse_addr = false) { bool reuse_addr = false) {
static_assert(std::is_convertible<actor_hdl, minimal_server>::value, static_assert(std::is_convertible<actor_hdl, accept_handler>::value,
"Cannot add doorman: broker misses required handlers"); "Cannot add doorman: broker misses required handlers");
return super::add_tcp_doorman(port, in, reuse_addr); return super::add_tcp_doorman(port, in, reuse_addr);
} }
accept_handle add_tcp_doorman(network::native_socket fd) { accept_handle add_tcp_doorman(network::native_socket fd) {
static_assert(std::is_convertible<actor_hdl, minimal_server>::value, static_assert(std::is_convertible<actor_hdl, accept_handler>::value,
"Cannot add doorman: broker misses required handlers"); "Cannot add doorman: broker misses required handlers");
return super::add_tcp_doorman(fd); return super::add_tcp_doorman(fd);
} }
...@@ -215,8 +221,7 @@ protected: ...@@ -215,8 +221,7 @@ protected:
} }
}; };
} // namespace experimental
} // namespace io } // namespace io
} // namespace caf } // namespace caf
#endif // CAF_IO_EXPERIMENTAL_TYPED_BROKER_HPP #endif // CAF_IO_TYPED_BROKER_HPP
...@@ -28,14 +28,11 @@ ...@@ -28,14 +28,11 @@
#include "caf/all.hpp" #include "caf/all.hpp"
#include "caf/io/all.hpp" #include "caf/io/all.hpp"
#include "caf/io/experimental/typed_broker.hpp"
#include "caf/string_algorithms.hpp" #include "caf/string_algorithms.hpp"
using namespace std; using namespace std;
using namespace caf; using namespace caf;
using namespace caf::io; using namespace caf::io;
using namespace caf::io::experimental;
namespace { namespace {
...@@ -44,11 +41,11 @@ using ping_atom = caf::atom_constant<atom("ping")>; ...@@ -44,11 +41,11 @@ using ping_atom = caf::atom_constant<atom("ping")>;
using pong_atom = caf::atom_constant<atom("pong")>; using pong_atom = caf::atom_constant<atom("pong")>;
using kickoff_atom = caf::atom_constant<atom("kickoff")>; using kickoff_atom = caf::atom_constant<atom("kickoff")>;
using peer = minimal_client::extend<reacts_to<ping_atom, int>, using peer = connection_handler::extend<reacts_to<ping_atom, int>,
reacts_to<pong_atom, int>>; reacts_to<pong_atom, int>>;
using acceptor = using acceptor =
minimal_server::extend<replies_to<publish_atom>::with<uint16_t>>; accept_handler::extend<replies_to<publish_atom>::with<uint16_t>>;
behavior ping(event_based_actor* self, size_t num_pings) { behavior ping(event_based_actor* self, size_t num_pings) {
CAF_MESSAGE("num_pings: " << num_pings); CAF_MESSAGE("num_pings: " << num_pings);
...@@ -165,12 +162,6 @@ acceptor::behavior_type acceptor_fun(acceptor::broker_pointer self, ...@@ -165,12 +162,6 @@ acceptor::behavior_type acceptor_fun(acceptor::broker_pointer self,
self->fork(peer_fun, msg.handle, buddy); self->fork(peer_fun, msg.handle, buddy);
self->quit(); self->quit();
}, },
[](const new_data_msg&) {
// nop
},
[](const connection_closed_msg&) {
// nop
},
[](const acceptor_closed_msg&) { [](const acceptor_closed_msg&) {
// nop // nop
}, },
......
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