From 43f75506adb211540fd423e71b5a68800cf89609 Mon Sep 17 00:00:00 2001 From: Dominik Charousset Date: Wed, 22 Aug 2012 11:45:05 +0200 Subject: [PATCH] relaxed signatures of link and monitor related member functions of class actor --- cppa/actor.hpp | 29 ++++------------------------- cppa/actor_proxy.hpp | 12 ++++++------ cppa/detail/abstract_actor.hpp | 12 ++++++------ src/actor.cpp | 20 -------------------- src/actor_proxy.cpp | 22 +++++++++++----------- 5 files changed, 27 insertions(+), 68 deletions(-) diff --git a/cppa/actor.hpp b/cppa/actor.hpp index 7e8e46f40e..538a3cd9ae 100644 --- a/cppa/actor.hpp +++ b/cppa/actor.hpp @@ -127,14 +127,14 @@ class actor : public channel { * @param other Actor instance that whose execution is coupled to the * execution of this Actor. */ - virtual void link_to(intrusive_ptr& other) = 0; + virtual void link_to(const intrusive_ptr& other) = 0; /** * @brief Unlinks this actor from @p other. * @param other Linked Actor. * @note Links are automatically removed if the Actor finishes execution. */ - virtual void unlink_from(intrusive_ptr& other) = 0; + virtual void unlink_from(const intrusive_ptr& other) = 0; /** * @brief Establishes a link relation between this actor and @p other. @@ -142,7 +142,7 @@ class actor : public channel { * @returns @c true if this actor is running and added @p other to its * list of linked actors; otherwise @c false. */ - virtual bool establish_backlink(intrusive_ptr& other) = 0; + virtual bool establish_backlink(const intrusive_ptr& other) = 0; /** * @brief Removes a link relation between this actor and @p other. @@ -150,28 +150,7 @@ class actor : public channel { * @returns @c true if this actor is running and removed @p other * from its list of linked actors; otherwise @c false. */ - virtual bool remove_backlink(intrusive_ptr& other) = 0; - - // rvalue support - /** - * @copydoc link_to(intrusive_ptr&) - */ - void link_to(intrusive_ptr&& other); - - /** - * @copydoc :unlink_from(intrusive_ptr&) - */ - void unlink_from(intrusive_ptr&& other); - - /** - * @copydoc remove_backlink(intrusive_ptr&) - */ - bool remove_backlink(intrusive_ptr&& other); - - /** - * @copydoc establish_backlink(intrusive_ptr&) - */ - bool establish_backlink(intrusive_ptr&& other); + virtual bool remove_backlink(const intrusive_ptr& other) = 0; /** * @brief Gets the {@link process_information} of the parent process. diff --git a/cppa/actor_proxy.hpp b/cppa/actor_proxy.hpp index c3cbd0d7bf..1ee8d0b82d 100644 --- a/cppa/actor_proxy.hpp +++ b/cppa/actor_proxy.hpp @@ -57,21 +57,21 @@ class actor_proxy : public detail::abstract_actor { void sync_enqueue(actor* sender, message_id_t id, any_tuple msg); - void link_to(intrusive_ptr& other); + void link_to(const intrusive_ptr& other); // do not cause to send this actor an "UNLINK" message // to the "original" remote actor - void local_link_to(intrusive_ptr& other); + void local_link_to(const intrusive_ptr& other); - void unlink_from(intrusive_ptr& other); + void unlink_from(const intrusive_ptr& other); // do not cause to send this actor an "UNLINK" message // to the "original" remote actor - void local_unlink_from(intrusive_ptr& other); + void local_unlink_from(const actor_ptr& other); - bool remove_backlink(intrusive_ptr& to); + bool remove_backlink(const intrusive_ptr& to); - bool establish_backlink(intrusive_ptr& to); + bool establish_backlink(const intrusive_ptr& to); }; diff --git a/cppa/detail/abstract_actor.hpp b/cppa/detail/abstract_actor.hpp index c0ce11ebba..1b466ac12f 100644 --- a/cppa/detail/abstract_actor.hpp +++ b/cppa/detail/abstract_actor.hpp @@ -139,15 +139,15 @@ class abstract_actor : public abstract_actor_base& other) { // override + void link_to(const intrusive_ptr& other) { (void) link_to_impl(other); } - void unlink_from(intrusive_ptr& other) { // override + void unlink_from(const intrusive_ptr& other) { (void) unlink_from_impl(other); } - bool remove_backlink(intrusive_ptr& other) { // override + bool remove_backlink(const intrusive_ptr& other) { if (other && other != this) { guard_type guard(m_mtx); auto i = std::find(m_links.begin(), m_links.end(), other); @@ -159,7 +159,7 @@ class abstract_actor : public abstract_actor_base& other) { // override + bool establish_backlink(const intrusive_ptr& other) { std::uint32_t reason = exit_reason::not_exited; if (other && other != this) { guard_type guard(m_mtx); @@ -252,7 +252,7 @@ class abstract_actor : public abstract_actor_base& other) { + bool link_to_impl(const intrusive_ptr& other) { if (other && other != this) { guard_type guard(m_mtx); // send exit message if already exited @@ -270,7 +270,7 @@ class abstract_actor : public abstract_actor_base& other) { + bool unlink_from_impl(const intrusive_ptr& other) { guard_type guard(m_mtx); // remove_backlink returns true if this actor is linked to other if (other && !exited() && other->remove_backlink(this)) { diff --git a/src/actor.cpp b/src/actor.cpp index 996c090f38..fd3791a5c0 100644 --- a/src/actor.cpp +++ b/src/actor.cpp @@ -78,24 +78,4 @@ actor::actor(const process_information_ptr& pptr) } } -void actor::link_to(intrusive_ptr&& other) { - intrusive_ptr tmp(std::move(other)); - link_to(tmp); -} - -void actor::unlink_from(intrusive_ptr&& other) { - intrusive_ptr tmp(std::move(other)); - unlink_from(tmp); -} - -bool actor::remove_backlink(intrusive_ptr&& to) { - intrusive_ptr tmp(std::move(to)); - return remove_backlink(tmp); -} - -bool actor::establish_backlink(intrusive_ptr&& to) { - intrusive_ptr tmp(std::move(to)); - return establish_backlink(tmp); -} - } // namespace cppa diff --git a/src/actor_proxy.cpp b/src/actor_proxy.cpp index fcf11a2fd8..0768462f30 100644 --- a/src/actor_proxy.cpp +++ b/src/actor_proxy.cpp @@ -35,6 +35,7 @@ #include "cppa/actor_proxy.hpp" #include "cppa/exit_reason.hpp" #include "cppa/detail/middleman.hpp" +#include "cppa/detail/types_array.hpp" #include "cppa/detail/network_manager.hpp" #include "cppa/detail/singleton_manager.hpp" @@ -45,15 +46,14 @@ namespace cppa { using detail::middleman_enqueue; actor_proxy::actor_proxy(std::uint32_t mid, const process_information_ptr& pptr) - : super(mid, pptr) { - //attach(get_scheduler()->register_hidden_context()); -} +: super(mid, pptr) { } void actor_proxy::enqueue(actor* sender, any_tuple msg) { + auto& arr = detail::static_types_array::arr; if ( msg.size() == 2 - && *(msg.type_at(0)) == typeid(atom_value) + && msg.type_at(0) == arr[0] && msg.get_as(0) == atom("KILL_PROXY") - && *(msg.type_at(1)) == typeid(std::uint32_t)) { + && msg.type_at(1) == arr[1]) { cleanup(msg.get_as(1)); return; } @@ -64,7 +64,7 @@ void actor_proxy::sync_enqueue(actor* sender, message_id_t id, any_tuple msg) { middleman_enqueue(parent_process_ptr(), sender, this, std::move(msg), id); } -void actor_proxy::link_to(intrusive_ptr& other) { +void actor_proxy::link_to(const intrusive_ptr& other) { if (link_to_impl(other)) { // causes remote actor to link to (proxy of) other middleman_enqueue(parent_process_ptr(), @@ -74,11 +74,11 @@ void actor_proxy::link_to(intrusive_ptr& other) { } } -void actor_proxy::local_link_to(intrusive_ptr& other) { +void actor_proxy::local_link_to(const intrusive_ptr& other) { link_to_impl(other); } -void actor_proxy::unlink_from(intrusive_ptr& other) { +void actor_proxy::unlink_from(const intrusive_ptr& other) { if (unlink_from_impl(other)) { // causes remote actor to unlink from (proxy of) other middleman_enqueue(parent_process_ptr(), @@ -88,11 +88,11 @@ void actor_proxy::unlink_from(intrusive_ptr& other) { } } -void actor_proxy::local_unlink_from(intrusive_ptr& other) { +void actor_proxy::local_unlink_from(const intrusive_ptr& other) { unlink_from_impl(other); } -bool actor_proxy::establish_backlink(intrusive_ptr& other) { +bool actor_proxy::establish_backlink(const intrusive_ptr& other) { bool result = super::establish_backlink(other); if (result) { // causes remote actor to unlink from (proxy of) other @@ -104,7 +104,7 @@ bool actor_proxy::establish_backlink(intrusive_ptr& other) { return result; } -bool actor_proxy::remove_backlink(intrusive_ptr& other) { +bool actor_proxy::remove_backlink(const intrusive_ptr& other) { bool result = super::remove_backlink(other); if (result) { middleman_enqueue(parent_process_ptr(),