From: Martin Quinson Date: Wed, 29 Aug 2018 20:04:11 +0000 (+0200) Subject: simplify the actor finalization a tiny bit by using a callback X-Git-Tag: v3_21~134 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/03ce6a2e7863fe994d12ca8ab9141b4f6fdb5f8e simplify the actor finalization a tiny bit by using a callback This is part of the removal of all trace-related pimpl all over the code of MSG (my goal is to kill MSG_process_cleanup_from_SIMIX() all together). Note that I changed from Container::by_name() to Container::by_name_or_null. It seems that not all actors have a container by their name, not sure why. --- diff --git a/src/instr/instr_paje_containers.cpp b/src/instr/instr_paje_containers.cpp index 52994b4a5b..e0c22b18d2 100644 --- a/src/instr/instr_paje_containers.cpp +++ b/src/instr/instr_paje_containers.cpp @@ -129,8 +129,7 @@ Container* Container::by_name_or_null(std::string name) Container* Container::by_name(std::string name) { Container* ret = Container::by_name_or_null(name); - if (ret == nullptr) - THROWF(tracing_error, 1, "container with name %s not found", name.c_str()); + xbt_assert(ret != nullptr, "container with name %s not found", name.c_str()); return ret; } diff --git a/src/instr/instr_platform.cpp b/src/instr/instr_platform.cpp index 1901f25bcb..5ec364e698 100644 --- a/src/instr/instr_platform.cpp +++ b/src/instr/instr_platform.cpp @@ -372,6 +372,11 @@ void instr_define_callbacks() if (TRACE_actor_is_enabled()) { simgrid::s4u::Actor::on_creation.connect(instr_actor_on_creation); + simgrid::s4u::Actor::on_destruction.connect([](simgrid::s4u::ActorPtr actor) { + auto container = simgrid::instr::Container::by_name_or_null(instr_pid(actor.get())); + if (container != nullptr) + container->remove_from_parent(); + }); simgrid::s4u::Actor::on_suspend.connect([](simgrid::s4u::ActorPtr actor) { simgrid::instr::Container::by_name(instr_pid(actor.get()))->get_state("ACTOR_STATE")->push_event("suspend"); }); diff --git a/src/msg/msg_process.cpp b/src/msg/msg_process.cpp index 16311deb63..590bd240ab 100644 --- a/src/msg/msg_process.cpp +++ b/src/msg/msg_process.cpp @@ -32,9 +32,6 @@ std::string instr_pid(msg_process_t proc) */ void MSG_process_cleanup_from_SIMIX(smx_actor_t smx_actor) { - if (TRACE_actor_is_enabled()) - simgrid::instr::Container::by_name(instr_pid(smx_actor->ciface()))->remove_from_parent(); - // free the data if a function was provided void* userdata = smx_actor->get_user_data(); if (userdata && msg_global->process_data_cleanup) {