Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add detailed stress test for WakeupTree
[simgrid.git] / src / xbt / dict.cpp
index bbc45999c55fab2af2a45d68f7a019314ed2d6e6..f1e73d31dc7c81573810e6f0c394af7015c5ee80 100644 (file)
@@ -17,6 +17,7 @@
 #include <algorithm>
 #include <cstdio>
 #include <cstring>
+#include <mutex>
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_dict, xbt, "Dictionaries provide the same functionalities as hash tables");
 
@@ -32,6 +33,8 @@ static void xbt_dict_postexit()
 }
 static void xbt_dict_preinit()
 {
+  static std::mutex init_mutex;
+  const std::scoped_lock lock(init_mutex);
   if (dict_elm_mallocator == nullptr) {
     dict_elm_mallocator =
         xbt_mallocator_new(256, dict_elm_mallocator_new_f, dict_elm_mallocator_free_f, dict_elm_mallocator_reset_f);