From 63c38b9be23481f3c9117957c783a7dad4a29637 Mon Sep 17 00:00:00 2001 From: Jean Pierre Cimalando Date: Tue, 12 Oct 2021 20:26:25 +0200 Subject: [PATCH] One-time EEL init with mutex guard --- source/modules/jsusfx/source/jsusfx.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/source/modules/jsusfx/source/jsusfx.cpp b/source/modules/jsusfx/source/jsusfx.cpp index b5716ec0f..a23d1eeae 100644 --- a/source/modules/jsusfx/source/jsusfx.cpp +++ b/source/modules/jsusfx/source/jsusfx.cpp @@ -27,6 +27,7 @@ #include "WDL/ptrlist.h" #include "WDL/assocarray.h" +#include "WDL/mutex.h" #define REAPER_GET_INTERFACE(opaque) ((opaque) ? ((JsusFx*)opaque) : nullptr) @@ -1208,12 +1209,24 @@ void JsusFx::releaseCode() { NSEEL_VM_remove_all_nonreg_vars(m_vm); } +static WDL_Mutex initMutex; +static volatile bool initFlag = false; + void JsusFx::init() { + if (initFlag) + return; + + WDL_MutexLock lock(&initMutex); + if (initFlag) + return; + EEL_string_register(); EEL_fft_register(); EEL_mdct_register(); EEL_string_register(); EEL_misc_register(); + + initFlag = true; } static int dumpvarsCallback(const char *name, EEL_F *val, void *ctx) {