void manager::detach(execution_unit*, bool invoke_disconnect_message) { CAF_LOG_TRACE(CAF_ARG(invoke_disconnect_message)); // This function gets called from the multiplexer when an error occurs or // from the broker when closing this manager. In both cases, we need to make // sure this manager does not receive further socket events. remove_from_loop(); // Disconnect from the broker if not already detached. if (!detached()) { CAF_LOG_DEBUG("disconnect servant from broker"); auto raw_ptr = parent(); // Keep a strong reference to our parent until we go out of scope. strong_actor_ptr ptr; ptr.swap(parent_); detach_from(raw_ptr); if (invoke_disconnect_message) { auto mptr = make_mailbox_element(nullptr, invalid_message_id, {}, detach_message()); switch (raw_ptr->consume(*mptr)) { case im_success: raw_ptr->finalize(); break; case im_skipped: raw_ptr->push_to_cache(std::move(mptr)); break; case im_dropped: CAF_LOG_INFO("broker dropped disconnect message"); break; } } } }
void manager::detach(bool invoke_disconnect_message) { BOOST_ACTOR_LOG_TRACE(""); if (! detached()) { BOOST_ACTOR_LOG_DEBUG("disconnect servant from broker"); detach_from_parent(); if (invoke_disconnect_message) { auto msg = detach_message(); parent_->invoke_message(parent_->address(),invalid_message_id, msg); } parent_ = nullptr; } }