From 6597707ea6cedd1fbc6ed232fa2494eb26d74a51 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Thu, 19 May 2022 19:52:22 -0600 Subject: [PATCH] Use std::call_once() instead of hand-rolling a solution. --- source/base/multithread_info.cc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) 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() -- 2.39.5