Commit 4a61bd68 authored by Dominik Charousset's avatar Dominik Charousset

Cleanup publish() and remote_actor() impls

parent c38a1608
......@@ -35,15 +35,14 @@ namespace caf {
namespace io {
template <class... Ts>
void publish_impl(abstract_actor_ptr whom, uint16_t port, Ts&&... args) {
void publish_impl(abstract_actor_ptr whom, uint16_t port, const char* in) {
using namespace detail;
auto mm = middleman::instance();
std::promise<bool> res;
mm->run_later([&] {
auto bro = mm->get_named_broker<basp_broker>(atom("_BASP"));
try {
auto hdl = mm->backend().add_tcp_doorman(bro.get(), port,
std::forward<Ts>(args)...);
auto hdl = mm->backend().add_tcp_doorman(bro.get(), port, in);
bro->announce_published_actor(hdl, whom);
mm->notify<hook::actor_published>(whom->address(), port);
res.set_value(true);
......
......@@ -34,62 +34,26 @@
namespace caf {
namespace io {
/**
* Establish a new connection to a remote actor via `connection`.
* @param connection A connection to another process described by a pair
* of input and output stream.
* @returns An {@link actor_ptr} to the proxy instance
* representing a remote actor.
* @throws std::invalid_argument Thrown when connecting to a typed actor.
*/
template <class Socket>
inline actor remote_actor(Socket fd) {
auto res = remote_actor_impl(std::move(fd), std::set<std::string>{});
return actor_cast<actor>(res);
}
/**
* Establish a new connection to the actor at `host` on given `port`.
* @param host Valid hostname or IP address.
* @param port TCP port.
* @returns An {@link actor_ptr} to the proxy instance
* representing a remote actor.
* representing a remote actor.
* @throws std::invalid_argument Thrown when connecting to a typed actor.
*/
inline actor remote_actor(const char* host, uint16_t port) {
auto res = remote_actor_impl(std::set<std::string>{}, host, port);
return actor_cast<actor>(res);
}
/**
* @copydoc remote_actor(const char*, uint16_t)
*/
inline actor remote_actor(const std::string& host, uint16_t port) {
auto res = remote_actor_impl(std::set<std::string>{}, host, port);
return actor_cast<actor>(res);
}
/**
* @copydoc remote_actor(stream_ptr_pair)
*/
template <class List, class Socket>
typename typed_remote_actor_helper<List>::return_type
typed_remote_actor(Socket fd) {
typed_remote_actor_helper<List> f;
return f(std::move(fd));
}
/**
* @copydoc remote_actor(const char*,uint16_t)
*/
template <class List>
typename typed_remote_actor_helper<List>::return_type
typed_remote_actor(const char* host, uint16_t port) {
typed_remote_actor_helper<List> f;
return f(host, port);
}
/**
* @copydoc remote_actor(const std::string&,uint16_t)
* Establish a new connection to the typed actor at `host` on given `port`.
* @param host Valid hostname or IP address.
* @param port TCP port.
* @returns An {@link actor_ptr} to the proxy instance
* representing a typed remote actor.
* @throws std::invalid_argument Thrown when connecting to a typed actor.
*/
template <class List>
typename typed_remote_actor_helper<List>::return_type
......
......@@ -40,15 +40,9 @@
namespace caf {
namespace io {
constexpr uint32_t max_iface_size = 100;
constexpr uint32_t max_iface_clause_size = 500;
using string_set = std::set<std::string>;
template <class... Ts>
abstract_actor_ptr remote_actor_impl(const std::set<std::string>& ifs,
Ts&&... args) {
const std::string& host, uint16_t port) {
auto mm = middleman::instance();
std::string error_msg;
std::promise<abstract_actor_ptr> result_promise;
......@@ -57,8 +51,7 @@ abstract_actor_ptr remote_actor_impl(const std::set<std::string>& ifs,
mm->run_later([&] {
try {
auto bro = mm->get_named_broker<basp_broker>(atom("_BASP"));
auto hdl = mm->backend().add_tcp_scribe(bro.get(),
std::forward<Ts>(args)...);
auto hdl = mm->backend().add_tcp_scribe(bro.get(), host, port);
bro->init_client(hdl, &hdata);
}
catch (...) {
......
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