From 2e1a9d70da2b7bb7d12d3d012365f864fd9ee85b Mon Sep 17 00:00:00 2001 From: conrad Date: Mon, 6 May 2024 22:23:49 +1000 Subject: [PATCH] simplification --- include/armadillo_bits/fft_engine_fftw3.hpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/include/armadillo_bits/fft_engine_fftw3.hpp b/include/armadillo_bits/fft_engine_fftw3.hpp index b0bc6bf8..a5070648 100644 --- a/include/armadillo_bits/fft_engine_fftw3.hpp +++ b/include/armadillo_bits/fft_engine_fftw3.hpp @@ -23,6 +23,13 @@ #if defined(ARMA_USE_FFTW3) +struct fft_engine_fftw3_aux + { + #if defined(ARMA_USE_STD_MUTEX) + static inline std::mutex& get_plan_mutex() { static std::mutex plan_mutex; return plan_mutex; } + #endif + }; + template class fft_engine_fftw3 { @@ -87,11 +94,7 @@ class fft_engine_fftw3 } #elif defined(ARMA_USE_STD_MUTEX) { - // NOTE: this is a "better-than-nothing" solution; - // NOTE: the static std::mutex variable is only common across instances of the same fft_engine_fftw3 class type; - // NOTE: varying the template args will result in separate std::mutex variables - - static std::mutex plan_mutex; + std::mutex& plan_mutex = fft_engine_fftw3_aux::get_plan_mutex(); const std::lock_guard lock(plan_mutex);