Commit a481bdbf authored by Dominik Charousset's avatar Dominik Charousset

Merge pull request #405 from ufownl/topic/fix_compilation_error

Fix compilation error on gcc4.8
parents 00fba105 ea445eaf
...@@ -53,6 +53,10 @@ public: ...@@ -53,6 +53,10 @@ public:
/// @cond PRIVATE /// @cond PRIVATE
/// Called by the runtime system to perform cleanup actions for this actor.
/// Subtypes should always call this member function when overriding it.
virtual void cleanup(exit_reason reason, execution_unit* host);
// Returns `exit_reason_ != exit_reason::not_exited`. // Returns `exit_reason_ != exit_reason::not_exited`.
inline bool exited() const { inline bool exited() const {
return exit_reason_ != exit_reason::not_exited; return exit_reason_ != exit_reason::not_exited;
...@@ -70,10 +74,6 @@ protected: ...@@ -70,10 +74,6 @@ protected:
/// Creates a new actor instance. /// Creates a new actor instance.
monitorable_actor(actor_system* sys, actor_id aid, node_id nid, int flags); monitorable_actor(actor_system* sys, actor_id aid, node_id nid, int flags);
/// Called by the runtime system to perform cleanup actions for this actor.
/// Subtypes should always call this member function when overriding it.
virtual void cleanup(exit_reason reason, execution_unit* host);
/**************************************************************************** /****************************************************************************
* here be dragons: end of public interface * * here be dragons: end of public interface *
****************************************************************************/ ****************************************************************************/
......
...@@ -55,6 +55,25 @@ size_t monitorable_actor::detach(const attachable::token& what) { ...@@ -55,6 +55,25 @@ size_t monitorable_actor::detach(const attachable::token& what) {
return detach_impl(what, attachables_head_); return detach_impl(what, attachables_head_);
} }
void monitorable_actor::cleanup(exit_reason reason, execution_unit* host) {
CAF_LOG_TRACE(CAF_ARG(reason));
CAF_ASSERT(reason != exit_reason::not_exited);
// move everyhting out of the critical section before processing it
attachable_ptr head;
{ // lifetime scope of guard
std::unique_lock<std::mutex> guard{mtx_};
if (exit_reason_ != exit_reason::not_exited)
return;
exit_reason_ = reason;
attachables_head_.swap(head);
}
CAF_LOG_INFO_IF(host && host->system().node() == node(),
"cleanup" << CAF_ARG(id()) << CAF_ARG(reason));
// send exit messages
for (attachable* i = head.get(); i != nullptr; i = i->next.get())
i->actor_exited(this, reason, host);
}
monitorable_actor::monitorable_actor(actor_config& cfg) monitorable_actor::monitorable_actor(actor_config& cfg)
: abstract_actor(cfg), : abstract_actor(cfg),
exit_reason_(exit_reason::not_exited) { exit_reason_(exit_reason::not_exited) {
...@@ -76,25 +95,6 @@ monitorable_actor::monitorable_actor(actor_system* sys, actor_id aid, ...@@ -76,25 +95,6 @@ monitorable_actor::monitorable_actor(actor_system* sys, actor_id aid,
// nop // nop
} }
void monitorable_actor::cleanup(exit_reason reason, execution_unit* host) {
CAF_LOG_TRACE(CAF_ARG(reason));
CAF_ASSERT(reason != exit_reason::not_exited);
// move everyhting out of the critical section before processing it
attachable_ptr head;
{ // lifetime scope of guard
std::unique_lock<std::mutex> guard{mtx_};
if (exit_reason_ != exit_reason::not_exited)
return;
exit_reason_ = reason;
attachables_head_.swap(head);
}
CAF_LOG_INFO_IF(host && host->system().node() == node(),
"cleanup" << CAF_ARG(id()) << CAF_ARG(reason));
// send exit messages
for (attachable* i = head.get(); i != nullptr; i = i->next.get())
i->actor_exited(this, reason, host);
}
maybe<exit_reason> monitorable_actor::handle(const std::exception_ptr& eptr) { maybe<exit_reason> monitorable_actor::handle(const std::exception_ptr& eptr) {
std::unique_lock<std::mutex> guard{mtx_}; std::unique_lock<std::mutex> guard{mtx_};
for (auto i = attachables_head_.get(); i != nullptr; i = i->next.get()) { for (auto i = attachables_head_.get(); i != nullptr; i = i->next.get()) {
......
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