Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Convert simix_global->process_to_destroy to boost::intrusive::list.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 5 Dec 2017 15:31:32 +0000 (16:31 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 5 Dec 2017 16:30:10 +0000 (17:30 +0100)
That was the last xbt_swag in C++ code. \o/

src/simix/ActorImpl.cpp
src/simix/ActorImpl.hpp
src/simix/smx_global.cpp
src/simix/smx_private.hpp

index 1491a9e..f727f48 100644 (file)
@@ -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<simgrid::simix::Host>()->process_list, *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<simgrid::simix::Host>()->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
 #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;
 
   }
   process->context->iwannadie = 0;
 
@@ -133,12 +133,11 @@ void SIMIX_process_cleanup(smx_actor_t process)
  */
 void SIMIX_process_empty_trash()
 {
  */
 void SIMIX_process_empty_trash()
 {
-  smx_actor_t process = static_cast<smx_actor_t>(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);
     XBT_DEBUG("Getting rid of %p",process);
     intrusive_ptr_release(process);
-    process = static_cast<smx_actor_t>(xbt_swag_extract(simix_global->process_to_destroy));
   }
 #if SIMGRID_HAVE_MC
   xbt_dynar_reset(simix_global->dead_actors_vector);
   }
 #if SIMGRID_HAVE_MC
   xbt_dynar_reset(simix_global->dead_actors_vector);
index 2fef6c2..03966bf 100644 (file)
@@ -9,7 +9,6 @@
 #include "simgrid/s4u/Actor.hpp"
 #include "src/simix/popping_private.hpp"
 #include "src/surf/PropertyHolder.hpp"
 #include "simgrid/s4u/Actor.hpp"
 #include "src/simix/popping_private.hpp"
 #include "src/surf/PropertyHolder.hpp"
-#include "xbt/swag.h"
 #include <boost/intrusive/list.hpp>
 #include <list>
 #include <map>
 #include <boost/intrusive/list.hpp>
 #include <list>
 #include <map>
@@ -38,9 +37,8 @@ public:
   ActorImpl() : piface_(this) {}
   ~ActorImpl();
 
   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<> 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;
   boost::intrusive::list_member_hook<> smx_synchro_hook;       /* {mutex,cond,sem}->sleeping */
 
   aid_t pid  = 0;
index 8ba76bd..6be0478 100644 (file)
@@ -212,7 +212,6 @@ void SIMIX_global_init(int *argc, char **argv)
     simix_global = std::unique_ptr<simgrid::simix::Global>(new simgrid::simix::Global());
 
     simgrid::simix::ActorImpl proc;
     simix_global = std::unique_ptr<simgrid::simix::Global>(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;
     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();
   /* 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_list.clear();
-  simix_global->process_to_destroy = nullptr;
 
   xbt_os_mutex_destroy(simix_global->mutex);
   simix_global->mutex = nullptr;
 
   xbt_os_mutex_destroy(simix_global->mutex);
   simix_global->mutex = nullptr;
index 55664e2..b0a6be6 100644 (file)
@@ -10,6 +10,7 @@
 #include "src/kernel/context/Context.hpp"
 #include <csignal>
 
 #include "src/kernel/context/Context.hpp"
 #include <csignal>
 
+#include <boost/intrusive/list.hpp>
 #include <map>
 #include <vector>
 
 #include <map>
 #include <vector>
 
@@ -26,7 +27,9 @@ public:
   std::vector<smx_actor_t> process_to_run;
   std::vector<smx_actor_t> process_that_ran;
   std::map<aid_t, smx_actor_t> process_list;
   std::vector<smx_actor_t> process_to_run;
   std::vector<smx_actor_t> process_that_ran;
   std::map<aid_t, smx_actor_t> process_list;
-  xbt_swag_t process_to_destroy = nullptr;
+  boost::intrusive::list<ActorImpl, boost::intrusive::member_hook<ActorImpl, boost::intrusive::list_member_hook<>,
+                                                                  &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.
 #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.