X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/efb91cad10e3ffdbce69f868e6cfa1df4b4a758b..16c3ee2d2a61e399f24130eb97c27b830023a9f0:/src/xbt/dict.cpp diff --git a/src/xbt/dict.cpp b/src/xbt/dict.cpp index 3d8703fc16..f1e73d31dc 100644 --- a/src/xbt/dict.cpp +++ b/src/xbt/dict.cpp @@ -33,15 +33,12 @@ 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) { - static std::mutex init_mutex; - init_mutex.lock(); - if (dict_elm_mallocator == nullptr) { // Just in case someone initialized it in between - dict_elm_mallocator = - xbt_mallocator_new(256, dict_elm_mallocator_new_f, dict_elm_mallocator_free_f, dict_elm_mallocator_reset_f); - atexit(xbt_dict_postexit); - } - init_mutex.unlock(); + dict_elm_mallocator = + xbt_mallocator_new(256, dict_elm_mallocator_new_f, dict_elm_mallocator_free_f, dict_elm_mallocator_reset_f); + atexit(xbt_dict_postexit); } }