Browse Source

jsfx: add support of atomic methods

pull/1514/head
Jean Pierre Cimalando 3 years ago
parent
commit
db29ec3cc6
2 changed files with 12 additions and 0 deletions
  1. +10
    -0
      source/modules/jsusfx/source/jsusfx.cpp
  2. +2
    -0
      source/modules/jsusfx/source/jsusfx.h

+ 10
- 0
source/modules/jsusfx/source/jsusfx.cpp View File

@@ -40,10 +40,17 @@
#define EEL_STRING_STDOUT_WRITE(x,len) { fwrite(x,len,1,stdout); fflush(stdout); } #define EEL_STRING_STDOUT_WRITE(x,len) { fwrite(x,len,1,stdout); fflush(stdout); }
#endif #endif
#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_strings.h"
#include "WDL/eel2/eel_misc.h" #include "WDL/eel2/eel_misc.h"
#include "WDL/eel2/eel_fft.h" #include "WDL/eel2/eel_fft.h"
#include "WDL/eel2/eel_mdct.h" #include "WDL/eel2/eel_mdct.h"
#include "WDL/eel2/eel_atomic.h"


#include <fstream> // to check if files exist #include <fstream> // to check if files exist


@@ -482,6 +489,7 @@ JsusFx::JsusFx(JsusFxPathLibrary &_pathLibrary)
NSEEL_VM_SetCustomFuncThis(m_vm,this); NSEEL_VM_SetCustomFuncThis(m_vm,this);


m_string_context = new eel_string_context_state(); m_string_context = new eel_string_context_state();
m_atomic_mutex = new WDL_Mutex;
eel_string_initvm(m_vm); eel_string_initvm(m_vm);
computeSlider = false; computeSlider = false;
srate = 0; srate = 0;
@@ -552,6 +560,7 @@ JsusFx::~JsusFx() {
if (m_vm) if (m_vm)
NSEEL_VM_free(m_vm); NSEEL_VM_free(m_vm);
delete m_string_context; delete m_string_context;
delete m_atomic_mutex;
} }


bool JsusFx::compileSection(int state, const char *code, int line_offset) { bool JsusFx::compileSection(int state, const char *code, int line_offset) {
@@ -1271,6 +1280,7 @@ void JsusFx::init() {
EEL_mdct_register(); EEL_mdct_register();
EEL_string_register(); EEL_string_register();
EEL_misc_register(); EEL_misc_register();
EEL_atomic_register();


initFlag = true; initFlag = true;
} }


+ 2
- 0
source/modules/jsusfx/source/jsusfx.h View File

@@ -42,6 +42,7 @@ class JsusFx_Slider;
struct JsusFx_Sections; struct JsusFx_Sections;


class WDL_FastString; class WDL_FastString;
class WDL_Mutex;


// //


@@ -267,4 +268,5 @@ public:
// ============================================================== // ==============================================================
eel_string_context_state *m_string_context; eel_string_context_state *m_string_context;
WDL_Mutex *m_atomic_mutex;
}; };

Loading…
Cancel
Save