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);