Commit 07f00977 authored by Dominik Charousset's avatar Dominik Charousset

added convenience overload to middleman_enqueue and use it consistently in actor_proxy

parent 9763e6fb
...@@ -73,11 +73,6 @@ class actor_proxy : public detail::abstract_actor<actor> { ...@@ -73,11 +73,6 @@ class actor_proxy : public detail::abstract_actor<actor> {
bool establish_backlink(intrusive_ptr<actor>& to); bool establish_backlink(intrusive_ptr<actor>& to);
void forward_message(const process_information_ptr&,
actor*,
any_tuple&&,
message_id_t = message_id_t() );
}; };
#endif // CPPA_DOCUMENTATION #endif // CPPA_DOCUMENTATION
......
...@@ -104,6 +104,16 @@ inline void middleman_enqueue(process_information_ptr peer, ...@@ -104,6 +104,16 @@ inline void middleman_enqueue(process_information_ptr peer,
send2mm(std::move(peer), std::move(outgoing_message)); send2mm(std::move(peer), std::move(outgoing_message));
} }
inline void middleman_enqueue(process_information_ptr peer,
actor_ptr sender,
channel_ptr receiver,
any_tuple&& msg,
message_id_t id = message_id_t()) {
addressed_message amsg(std::move(sender), std::move(receiver),
std::move(msg), id);
send2mm(std::move(peer), std::move(amsg));
}
} } // namespace cppa::detail } } // namespace cppa::detail
#endif // MIDDLEMAN_HPP #endif // MIDDLEMAN_HPP
...@@ -42,19 +42,13 @@ ...@@ -42,19 +42,13 @@
namespace cppa { namespace cppa {
using detail::middleman_enqueue;
actor_proxy::actor_proxy(std::uint32_t mid, const process_information_ptr& pptr) actor_proxy::actor_proxy(std::uint32_t mid, const process_information_ptr& pptr)
: super(mid, pptr) { : super(mid, pptr) {
//attach(get_scheduler()->register_hidden_context()); //attach(get_scheduler()->register_hidden_context());
} }
void actor_proxy::forward_message(const process_information_ptr& piptr,
actor* sender,
any_tuple&& msg,
message_id_t id ) {
detail::addressed_message amsg{sender, this, std::move(msg), id};
detail::middleman_enqueue(piptr, std::move(amsg));
}
void actor_proxy::enqueue(actor* sender, any_tuple msg) { void actor_proxy::enqueue(actor* sender, any_tuple msg) {
if ( msg.size() == 2 if ( msg.size() == 2
&& *(msg.type_at(0)) == typeid(atom_value) && *(msg.type_at(0)) == typeid(atom_value)
...@@ -63,19 +57,20 @@ void actor_proxy::enqueue(actor* sender, any_tuple msg) { ...@@ -63,19 +57,20 @@ void actor_proxy::enqueue(actor* sender, any_tuple msg) {
cleanup(msg.get_as<std::uint32_t>(1)); cleanup(msg.get_as<std::uint32_t>(1));
return; return;
} }
forward_message(parent_process_ptr(), sender, std::move(msg)); middleman_enqueue(parent_process_ptr(), sender, this, std::move(msg));
} }
void actor_proxy::sync_enqueue(actor* sender, message_id_t id, any_tuple msg) { void actor_proxy::sync_enqueue(actor* sender, message_id_t id, any_tuple msg) {
forward_message(parent_process_ptr(), sender, std::move(msg), id); middleman_enqueue(parent_process_ptr(), sender, this, std::move(msg), id);
} }
void actor_proxy::link_to(intrusive_ptr<actor>& other) { void actor_proxy::link_to(intrusive_ptr<actor>& other) {
if (link_to_impl(other)) { if (link_to_impl(other)) {
// causes remote actor to link to (proxy of) other // causes remote actor to link to (proxy of) other
forward_message(parent_process_ptr(), middleman_enqueue(parent_process_ptr(),
other.get(), other,
make_any_tuple(atom("LINK"), other)); this,
make_any_tuple(atom("LINK"), other));
} }
} }
...@@ -86,9 +81,10 @@ void actor_proxy::local_link_to(intrusive_ptr<actor>& other) { ...@@ -86,9 +81,10 @@ void actor_proxy::local_link_to(intrusive_ptr<actor>& other) {
void actor_proxy::unlink_from(intrusive_ptr<actor>& other) { void actor_proxy::unlink_from(intrusive_ptr<actor>& other) {
if (unlink_from_impl(other)) { if (unlink_from_impl(other)) {
// causes remote actor to unlink from (proxy of) other // causes remote actor to unlink from (proxy of) other
forward_message(parent_process_ptr(), middleman_enqueue(parent_process_ptr(),
other.get(), other,
make_any_tuple(atom("UNLINK"), other)); this,
make_any_tuple(atom("UNLINK"), other));
} }
} }
...@@ -100,9 +96,10 @@ bool actor_proxy::establish_backlink(intrusive_ptr<actor>& other) { ...@@ -100,9 +96,10 @@ bool actor_proxy::establish_backlink(intrusive_ptr<actor>& other) {
bool result = super::establish_backlink(other); bool result = super::establish_backlink(other);
if (result) { if (result) {
// causes remote actor to unlink from (proxy of) other // causes remote actor to unlink from (proxy of) other
forward_message(parent_process_ptr(), middleman_enqueue(parent_process_ptr(),
other.get(), other,
make_any_tuple(atom("LINK"), other)); this,
make_any_tuple(atom("LINK"), other));
} }
return result; return result;
} }
...@@ -110,9 +107,10 @@ bool actor_proxy::establish_backlink(intrusive_ptr<actor>& other) { ...@@ -110,9 +107,10 @@ bool actor_proxy::establish_backlink(intrusive_ptr<actor>& other) {
bool actor_proxy::remove_backlink(intrusive_ptr<actor>& other) { bool actor_proxy::remove_backlink(intrusive_ptr<actor>& other) {
bool result = super::remove_backlink(other); bool result = super::remove_backlink(other);
if (result) { if (result) {
forward_message(parent_process_ptr(), middleman_enqueue(parent_process_ptr(),
nullptr, nullptr,
make_any_tuple(atom("UNLINK"), actor_ptr(this))); this,
make_any_tuple(atom("UNLINK"), actor_ptr(this)));
} }
return result; return result;
} }
......
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