Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
use std::mutex instead of xbt_os_mutex_t in simix
authorMartin Quinson <martin.quinson@loria.fr>
Wed, 18 Jul 2018 20:03:26 +0000 (22:03 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Wed, 18 Jul 2018 20:03:26 +0000 (22:03 +0200)
src/simix/ActorImpl.cpp
src/simix/smx_global.cpp
src/simix/smx_private.hpp

index 5d33798..f6665e7 100644 (file)
@@ -69,7 +69,7 @@ void SIMIX_process_cleanup(smx_actor_t process)
     process->kill_timer = nullptr;
   }
 
     process->kill_timer = nullptr;
   }
 
-  xbt_os_mutex_acquire(simix_global->mutex);
+  simix_global->mutex.lock();
 
   /* cancel non-blocking communications */
   while (not process->comms.empty()) {
 
   /* cancel non-blocking communications */
   while (not process->comms.empty()) {
@@ -113,7 +113,7 @@ void SIMIX_process_cleanup(smx_actor_t process)
   }
   process->context_->iwannadie = 0;
 
   }
   process->context_->iwannadie = 0;
 
-  xbt_os_mutex_release(simix_global->mutex);
+  simix_global->mutex.unlock();
 }
 
 /**
 }
 
 /**
index e1fbbdf..c527f79 100644 (file)
@@ -185,7 +185,6 @@ void SIMIX_global_init(int *argc, char **argv)
     simix_global->create_process_function = &SIMIX_process_create;
     simix_global->kill_process_function = &kill_process;
     simix_global->cleanup_process_function = &SIMIX_process_cleanup;
     simix_global->create_process_function = &SIMIX_process_create;
     simix_global->kill_process_function = &kill_process;
     simix_global->cleanup_process_function = &SIMIX_process_cleanup;
-    simix_global->mutex = xbt_os_mutex_init();
 
     surf_init(argc, argv);      /* Initialize SURF structures */
     SIMIX_context_mod_init();
 
     surf_init(argc, argv);      /* Initialize SURF structures */
     SIMIX_context_mod_init();
@@ -267,8 +266,6 @@ void SIMIX_clean()
   simix_global->process_to_destroy.clear();
   simix_global->process_list.clear();
 
   simix_global->process_to_destroy.clear();
   simix_global->process_list.clear();
 
-  xbt_os_mutex_destroy(simix_global->mutex);
-  simix_global->mutex = nullptr;
 #if SIMGRID_HAVE_MC
   xbt_dynar_free(&simix_global->actors_vector);
   xbt_dynar_free(&simix_global->dead_actors_vector);
 #if SIMGRID_HAVE_MC
   xbt_dynar_free(&simix_global->actors_vector);
   xbt_dynar_free(&simix_global->dead_actors_vector);
index 6609bd1..ea586f1 100644 (file)
@@ -12,6 +12,7 @@
 #include <xbt/xbt_os_thread.h>
 
 #include <boost/intrusive/list.hpp>
 #include <xbt/xbt_os_thread.h>
 
 #include <boost/intrusive/list.hpp>
+#include <mutex>
 #include <unordered_map>
 #include <vector>
 
 #include <unordered_map>
 #include <vector>
 
@@ -56,7 +57,7 @@ public:
   void_pfn_smxprocess_t kill_process_function = nullptr;
   /** Callback used when killing a SMX_process */
   void_pfn_smxprocess_t cleanup_process_function = nullptr;
   void_pfn_smxprocess_t kill_process_function = nullptr;
   /** Callback used when killing a SMX_process */
   void_pfn_smxprocess_t cleanup_process_function = nullptr;
-  xbt_os_mutex_t mutex                           = nullptr;
+  std::mutex mutex;
 
   std::vector<simgrid::xbt::Task<void()>> tasks;
   std::vector<simgrid::xbt::Task<void()>> tasksTemp;
 
   std::vector<simgrid::xbt::Task<void()>> tasks;
   std::vector<simgrid::xbt::Task<void()>> tasksTemp;