Commit d7f07ff4 authored by Dominik Charousset's avatar Dominik Charousset

Remove `virtual` keyword from `cleanup`

At the time `cleanup` is called, the most derived class is already known and
hiding is perfectly fine to achieve the same behavior. Relates #180.
parent 05c294db
...@@ -239,7 +239,7 @@ class abstract_actor : public abstract_channel { ...@@ -239,7 +239,7 @@ class abstract_actor : public abstract_channel {
* Called by the runtime system to perform cleanup actions for this actor. * Called by the runtime system to perform cleanup actions for this actor.
* Subtypes should always call this member function when overriding it. * Subtypes should always call this member function when overriding it.
*/ */
virtual void cleanup(uint32_t reason); void cleanup(uint32_t reason);
bool establish_link_impl(const actor_addr& other); bool establish_link_impl(const actor_addr& other);
......
...@@ -506,7 +506,7 @@ class local_actor : public extend<abstract_actor>::with<mixin::memory_cached> { ...@@ -506,7 +506,7 @@ class local_actor : public extend<abstract_actor>::with<mixin::memory_cached> {
m_planned_exit_reason = value; m_planned_exit_reason = value;
} }
void cleanup(uint32_t reason) override; void cleanup(uint32_t reason);
inline mailbox_element* dummy_node() { inline mailbox_element* dummy_node() {
return &m_dummy_node; return &m_dummy_node;
......
...@@ -49,7 +49,7 @@ class mailbox_based : public Base { ...@@ -49,7 +49,7 @@ class mailbox_based : public Base {
return mailbox_element::create(std::forward<Ts>(args)...); return mailbox_element::create(std::forward<Ts>(args)...);
} }
void cleanup(uint32_t reason) override { void cleanup(uint32_t reason) {
detail::sync_request_bouncer f{reason}; detail::sync_request_bouncer f{reason};
m_mailbox.close(f); m_mailbox.close(f);
Base::cleanup(reason); Base::cleanup(reason);
......
...@@ -379,7 +379,7 @@ class broker : public extend<local_actor>:: ...@@ -379,7 +379,7 @@ class broker : public extend<local_actor>::
protected: protected:
broker(); broker();
void cleanup(uint32_t reason) override; void cleanup(uint32_t reason);
using scribe_pointer = intrusive_ptr<scribe>; using scribe_pointer = intrusive_ptr<scribe>;
......
...@@ -42,11 +42,8 @@ class middleman; ...@@ -42,11 +42,8 @@ class middleman;
class sync_request_info : public extend<memory_managed>:: class sync_request_info : public extend<memory_managed>::
with<mixin::memory_cached> { with<mixin::memory_cached> {
friend class detail::memory; friend class detail::memory;
public: public:
using pointer = sync_request_info*; using pointer = sync_request_info*;
~sync_request_info(); ~sync_request_info();
...@@ -56,30 +53,19 @@ class sync_request_info : public extend<memory_managed>:: ...@@ -56,30 +53,19 @@ class sync_request_info : public extend<memory_managed>::
message_id mid; // sync message ID message_id mid; // sync message ID
private: private:
sync_request_info(actor_addr sptr, message_id id); sync_request_info(actor_addr sptr, message_id id);
}; };
class remote_actor_proxy : public actor_proxy { class remote_actor_proxy : public actor_proxy {
using super = actor_proxy; using super = actor_proxy;
public: public:
remote_actor_proxy(actor_id mid, node_id pinfo, remote_actor_proxy(actor_id mid, node_id pinfo,
actor parent); actor parent);
void enqueue(const actor_addr&, message_id, message, void enqueue(const actor_addr&, message_id,
execution_unit*) override; message, execution_unit*) override;
void link_to(const actor_addr& other) override; bool link_impl(linking_operation op, const actor_addr& other) override;
void unlink_from(const actor_addr& other) override;
bool remove_backlink(const actor_addr& to) override;
bool establish_backlink(const actor_addr& to) override;
void local_link_to(const actor_addr& other) override; void local_link_to(const actor_addr& other) override;
...@@ -88,16 +74,11 @@ class remote_actor_proxy : public actor_proxy { ...@@ -88,16 +74,11 @@ class remote_actor_proxy : public actor_proxy {
void kill_proxy(uint32_t reason) override; void kill_proxy(uint32_t reason) override;
protected: protected:
~remote_actor_proxy(); ~remote_actor_proxy();
private: private:
void forward_msg(const actor_addr& sender, message_id mid, message msg);
void forward_msg(const actor_addr& sender, message_id mid,
message msg);
actor m_parent; actor m_parent;
}; };
using remote_actor_proxy_ptr = intrusive_ptr<remote_actor_proxy>; using remote_actor_proxy_ptr = intrusive_ptr<remote_actor_proxy>;
......
...@@ -72,24 +72,27 @@ void remote_actor_proxy::enqueue(const actor_addr& sender, message_id mid, ...@@ -72,24 +72,27 @@ void remote_actor_proxy::enqueue(const actor_addr& sender, message_id mid,
forward_msg(sender, mid, std::move(m)); forward_msg(sender, mid, std::move(m));
} }
void remote_actor_proxy::link_to(const actor_addr& other) { bool remote_actor_proxy::link_impl(linking_operation op,
if (link_to_impl(other)) { const actor_addr& other) {
switch (op) {
case establish_link_op:
if (establish_link_impl(other)) {
// causes remote actor to link to (proxy of) other // causes remote actor to link to (proxy of) other
// receiving peer will call: this->local_link_to(other) // receiving peer will call: this->local_link_to(other)
forward_msg(address(), message_id::invalid, forward_msg(address(), message_id::invalid,
make_message(atom("_Link"), other)); make_message(atom("_Link"), other));
return true;
} }
} return false;
case remove_link_op:
void remote_actor_proxy::unlink_from(const actor_addr& other) { if (remove_link_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_msg(address(), message_id::invalid, forward_msg(address(), message_id::invalid,
make_message(atom("_Unlink"), other)); make_message(atom("_Unlink"), other));
return true;
} }
} return false;
case establish_backlink_op:
bool remote_actor_proxy::establish_backlink(const actor_addr& other) {
if (super::establish_backlink(other)) { if (super::establish_backlink(other)) {
// causes remote actor to unlink from (proxy of) other // causes remote actor to unlink from (proxy of) other
forward_msg(address(), message_id::invalid, forward_msg(address(), message_id::invalid,
...@@ -97,9 +100,7 @@ bool remote_actor_proxy::establish_backlink(const actor_addr& other) { ...@@ -97,9 +100,7 @@ bool remote_actor_proxy::establish_backlink(const actor_addr& other) {
return true; return true;
} }
return false; return false;
} case remove_backlink_op:
bool remote_actor_proxy::remove_backlink(const actor_addr& other) {
if (super::remove_backlink(other)) { if (super::remove_backlink(other)) {
// causes remote actor to unlink from (proxy of) other // causes remote actor to unlink from (proxy of) other
forward_msg(address(), message_id::invalid, forward_msg(address(), message_id::invalid,
...@@ -107,14 +108,16 @@ bool remote_actor_proxy::remove_backlink(const actor_addr& other) { ...@@ -107,14 +108,16 @@ bool remote_actor_proxy::remove_backlink(const actor_addr& other) {
return true; return true;
} }
return false; return false;
}
return false;
} }
void remote_actor_proxy::local_link_to(const actor_addr& other) { void remote_actor_proxy::local_link_to(const actor_addr& other) {
link_to_impl(other); establish_link_impl(other);
} }
void remote_actor_proxy::local_unlink_from(const actor_addr& other) { void remote_actor_proxy::local_unlink_from(const actor_addr& other) {
unlink_from_impl(other); remove_link_impl(other);
} }
void remote_actor_proxy::kill_proxy(uint32_t reason) { void remote_actor_proxy::kill_proxy(uint32_t reason) {
......
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