X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/02fbf5e463830a439464adae8626cd4f2dad27fd..c91b5a0dff704f2fe08d3480a12cc15f1a8b4081:/src/simix/ActorImpl.cpp diff --git a/src/simix/ActorImpl.cpp b/src/simix/ActorImpl.cpp index 29ca5bfda2..f727f484aa 100644 --- a/src/simix/ActorImpl.cpp +++ b/src/simix/ActorImpl.cpp @@ -15,6 +15,7 @@ #include "xbt/functional.hpp" #include "xbt/log.h" #include "xbt/sysdep.h" +#include "xbt/utility.hpp" #include "simgrid/s4u/Host.hpp" @@ -112,9 +113,14 @@ void SIMIX_process_cleanup(smx_actor_t process) XBT_DEBUG("%p should not be run anymore",process); simix_global->process_list.erase(process->pid); - if (process->host) - xbt_swag_remove(process, process->host->extension()->process_list); - xbt_swag_insert(process, simix_global->process_to_destroy); + if (process->host && process->host_process_list_hook.is_linked()) + simgrid::xbt::intrusive_erase(process->host->extension()->process_list, *process); + if (not process->smx_destroy_list_hook.is_linked()) { +#if SIMGRID_HAVE_MC + xbt_dynar_push_as(simix_global->dead_actors_vector, smx_actor_t, process); +#endif + simix_global->process_to_destroy.push_back(*process); + } process->context->iwannadie = 0; xbt_os_mutex_release(simix_global->mutex); @@ -127,13 +133,15 @@ void SIMIX_process_cleanup(smx_actor_t process) */ void SIMIX_process_empty_trash() { - smx_actor_t process = static_cast(xbt_swag_extract(simix_global->process_to_destroy)); - - while (process) { + while (not simix_global->process_to_destroy.empty()) { + smx_actor_t process = &simix_global->process_to_destroy.front(); + simix_global->process_to_destroy.pop_front(); XBT_DEBUG("Getting rid of %p",process); intrusive_ptr_release(process); - process = static_cast(xbt_swag_extract(simix_global->process_to_destroy)); } +#if SIMGRID_HAVE_MC + xbt_dynar_reset(simix_global->dead_actors_vector); +#endif } namespace simgrid { @@ -340,7 +348,7 @@ smx_actor_t SIMIX_process_create(const char* name, std::function code, v host->extension_set(new simgrid::simix::Host()); /* Add the process to its host process list */ - xbt_swag_insert(process, host->extension()->process_list); + host->extension()->process_list.push_back(*process); XBT_DEBUG("Start context '%s'", process->name.c_str()); @@ -406,7 +414,7 @@ smx_actor_t SIMIX_process_attach(const char* name, void* data, const char* hostn process->setProperty(kv.first, kv.second); /* Add the process to it's host process list */ - xbt_swag_insert(process, host->extension()->process_list); + host->extension()->process_list.push_back(*process); /* Now insert it in the global process list and in the process to run list */ simix_global->process_list[process->pid] = process; @@ -598,9 +606,9 @@ void SIMIX_process_killall(smx_actor_t issuer, int reset_pid) void SIMIX_process_change_host(smx_actor_t process, sg_host_t dest) { xbt_assert((process != nullptr), "Invalid parameters"); - xbt_swag_remove(process, process->host->extension()->process_list); + simgrid::xbt::intrusive_erase(process->host->extension()->process_list, *process); process->host = dest; - xbt_swag_insert(process, dest->extension()->process_list); + dest->extension()->process_list.push_back(*process); } void simcall_HANDLER_process_suspend(smx_simcall_t simcall, smx_actor_t process)