From: Wolfgang Bangerth Date: Fri, 20 May 2022 01:52:22 +0000 (-0600) Subject: Use std::call_once() instead of hand-rolling a solution. X-Git-Tag: v9.4.0-rc1~192^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F13762%2Fhead;p=dealii.git Use std::call_once() instead of hand-rolling a solution. --- diff --git a/source/base/multithread_info.cc b/source/base/multithread_info.cc index f9d6c984d2..1112b88efe 100644 --- a/source/base/multithread_info.cc +++ b/source/base/multithread_info.cc @@ -18,6 +18,7 @@ #include #include // for std::getenv +#include #include #ifdef DEAL_II_WITH_TBB @@ -144,14 +145,14 @@ MultithreadInfo::memory_consumption() void MultithreadInfo::initialize_multithreading() { - static bool done = false; - if (done) - return; - - MultithreadInfo::set_thread_limit(numbers::invalid_unsigned_int); - done = true; + static std::once_flag is_initialized; + std::call_once(is_initialized, []() { + MultithreadInfo::set_thread_limit(numbers::invalid_unsigned_int); + }); } + + #ifdef DEAL_II_WITH_TASKFLOW tf::Executor & MultithreadInfo::get_taskflow_executor()