From c91b5a0dff704f2fe08d3480a12cc15f1a8b4081 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Tue, 5 Dec 2017 16:31:32 +0100 Subject: [PATCH] Convert simix_global->process_to_destroy to boost::intrusive::list. That was the last xbt_swag in C++ code. \o/ --- src/simix/ActorImpl.cpp | 11 +++++------ src/simix/ActorImpl.hpp | 4 +--- src/simix/smx_global.cpp | 4 +--- src/simix/smx_private.hpp | 5 ++++- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/simix/ActorImpl.cpp b/src/simix/ActorImpl.cpp index 1491a9e4c6..f727f484aa 100644 --- a/src/simix/ActorImpl.cpp +++ b/src/simix/ActorImpl.cpp @@ -115,11 +115,11 @@ void SIMIX_process_cleanup(smx_actor_t process) simix_global->process_list.erase(process->pid); if (process->host && process->host_process_list_hook.is_linked()) simgrid::xbt::intrusive_erase(process->host->extension()->process_list, *process); - if (not xbt_swag_belongs(process, simix_global->process_to_destroy)) { + 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 - xbt_swag_insert(process, simix_global->process_to_destroy); + simix_global->process_to_destroy.push_back(*process); } process->context->iwannadie = 0; @@ -133,12 +133,11 @@ 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); diff --git a/src/simix/ActorImpl.hpp b/src/simix/ActorImpl.hpp index 2fef6c258f..03966bf846 100644 --- a/src/simix/ActorImpl.hpp +++ b/src/simix/ActorImpl.hpp @@ -9,7 +9,6 @@ #include "simgrid/s4u/Actor.hpp" #include "src/simix/popping_private.hpp" #include "src/surf/PropertyHolder.hpp" -#include "xbt/swag.h" #include #include #include @@ -38,9 +37,8 @@ public: ActorImpl() : piface_(this) {} ~ActorImpl(); - // TODO, replace with boost intrusive container hooks (src/mc/mc_smx.cpp needs to be changed too) - s_xbt_swag_hookup_t destroy_hookup = { nullptr, nullptr }; /* simix_global->process_to_destroy */ boost::intrusive::list_member_hook<> host_process_list_hook; /* simgrid::simix::Host::process_list */ + boost::intrusive::list_member_hook<> smx_destroy_list_hook; /* simix_global->process_to_destroy */ boost::intrusive::list_member_hook<> smx_synchro_hook; /* {mutex,cond,sem}->sleeping */ aid_t pid = 0; diff --git a/src/simix/smx_global.cpp b/src/simix/smx_global.cpp index 8ba76bd5dc..6be047874c 100644 --- a/src/simix/smx_global.cpp +++ b/src/simix/smx_global.cpp @@ -212,7 +212,6 @@ void SIMIX_global_init(int *argc, char **argv) simix_global = std::unique_ptr(new simgrid::simix::Global()); simgrid::simix::ActorImpl proc; - simix_global->process_to_destroy = xbt_swag_new(xbt_swag_offset(proc, destroy_hookup)); simix_global->maestro_process = nullptr; simix_global->create_process_function = &SIMIX_process_create; simix_global->kill_process_function = &kill_process; @@ -300,9 +299,8 @@ void SIMIX_clean() /* Free the remaining data structures */ simix_global->process_to_run.clear(); simix_global->process_that_ran.clear(); - xbt_swag_free(simix_global->process_to_destroy); + simix_global->process_to_destroy.clear(); simix_global->process_list.clear(); - simix_global->process_to_destroy = nullptr; xbt_os_mutex_destroy(simix_global->mutex); simix_global->mutex = nullptr; diff --git a/src/simix/smx_private.hpp b/src/simix/smx_private.hpp index 55664e28cf..b0a6be6d75 100644 --- a/src/simix/smx_private.hpp +++ b/src/simix/smx_private.hpp @@ -10,6 +10,7 @@ #include "src/kernel/context/Context.hpp" #include +#include #include #include @@ -26,7 +27,9 @@ public: std::vector process_to_run; std::vector process_that_ran; std::map process_list; - xbt_swag_t process_to_destroy = nullptr; + boost::intrusive::list, + &ActorImpl::smx_destroy_list_hook>> + process_to_destroy; #if SIMGRID_HAVE_MC /* MCer cannot read members process_list and process_to_destroy above in the remote process, so we copy the info it * needs in a dynar. -- 2.20.1