From db29ec3cc67d2e8d1cc7c3571e1a0a509fb618b7 Mon Sep 17 00:00:00 2001 From: Jean Pierre Cimalando Date: Wed, 3 Nov 2021 01:59:51 +0100 Subject: [PATCH] jsfx: add support of atomic methods --- source/modules/jsusfx/source/jsusfx.cpp | 10 ++++++++++ source/modules/jsusfx/source/jsusfx.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/source/modules/jsusfx/source/jsusfx.cpp b/source/modules/jsusfx/source/jsusfx.cpp index 487e9815c..cae229118 100644 --- a/source/modules/jsusfx/source/jsusfx.cpp +++ b/source/modules/jsusfx/source/jsusfx.cpp @@ -40,10 +40,17 @@ #define EEL_STRING_STDOUT_WRITE(x,len) { fwrite(x,len,1,stdout); fflush(stdout); } #endif #endif + +static WDL_Mutex atomic_mutex; +#define EEL_ATOMIC_SET_SCOPE(opaque) WDL_Mutex *mutex = (opaque ? ((JsusFx*)opaque)->m_atomic_mutex : &atomic_mutex); +#define EEL_ATOMIC_ENTER mutex->Enter() +#define EEL_ATOMIC_LEAVE mutex->Leave() + #include "WDL/eel2/eel_strings.h" #include "WDL/eel2/eel_misc.h" #include "WDL/eel2/eel_fft.h" #include "WDL/eel2/eel_mdct.h" +#include "WDL/eel2/eel_atomic.h" #include // to check if files exist @@ -482,6 +489,7 @@ JsusFx::JsusFx(JsusFxPathLibrary &_pathLibrary) NSEEL_VM_SetCustomFuncThis(m_vm,this); m_string_context = new eel_string_context_state(); + m_atomic_mutex = new WDL_Mutex; eel_string_initvm(m_vm); computeSlider = false; srate = 0; @@ -552,6 +560,7 @@ JsusFx::~JsusFx() { if (m_vm) NSEEL_VM_free(m_vm); delete m_string_context; + delete m_atomic_mutex; } bool JsusFx::compileSection(int state, const char *code, int line_offset) { @@ -1271,6 +1280,7 @@ void JsusFx::init() { EEL_mdct_register(); EEL_string_register(); EEL_misc_register(); + EEL_atomic_register(); initFlag = true; } diff --git a/source/modules/jsusfx/source/jsusfx.h b/source/modules/jsusfx/source/jsusfx.h index a11f24e97..ea7532ff7 100644 --- a/source/modules/jsusfx/source/jsusfx.h +++ b/source/modules/jsusfx/source/jsusfx.h @@ -42,6 +42,7 @@ class JsusFx_Slider; struct JsusFx_Sections; class WDL_FastString; +class WDL_Mutex; // @@ -267,4 +268,5 @@ public: // ============================================================== eel_string_context_state *m_string_context; + WDL_Mutex *m_atomic_mutex; };