From 12ab4c4aaf9c6e4037a0ffb88b2e8615cbc4d830 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Sun, 10 Aug 2014 04:21:24 +1000 Subject: Thread all of compiling, or thread nothing. --- src/LuaSL/LuaSL.h | 1 - src/LuaSL/LuaSL_LSL_tree.h | 1 + src/LuaSL/LuaSL_compile.c | 4 +--- src/libraries/Runnr.c | 12 +++++++++--- src/libraries/Runnr.h | 2 +- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/LuaSL/LuaSL.h b/src/LuaSL/LuaSL.h index f696f03..54e7fa7 100644 --- a/src/LuaSL/LuaSL.h +++ b/src/LuaSL/LuaSL.h @@ -12,7 +12,6 @@ typedef struct _gameGlobals gameGlobals; // Define this here, so LuaSL_threads.h #include "LumbrJack.h" #include "Runnr.h" -#define COMPILE_THREADED 0 struct _gameGlobals { diff --git a/src/LuaSL/LuaSL_LSL_tree.h b/src/LuaSL/LuaSL_LSL_tree.h index 30a12f5..5b61926 100644 --- a/src/LuaSL/LuaSL_LSL_tree.h +++ b/src/LuaSL/LuaSL_LSL_tree.h @@ -3,6 +3,7 @@ #define __LUASL_TREE_H__ #define LUASL_DEBUG 0 +#define COMPILE_THREADED 0 #define LUASL_DIFF_CHECK 0 #define LUASL_BAD_CHECK 0 diff --git a/src/LuaSL/LuaSL_compile.c b/src/LuaSL/LuaSL_compile.c index 5da2724..286681e 100644 --- a/src/LuaSL/LuaSL_compile.c +++ b/src/LuaSL/LuaSL_compile.c @@ -2373,9 +2373,7 @@ boolean compileLSL(LuaSL_compiler *compiler) // Compile the Lua source code. compiler->compiler.luaName = strdup(luaName); compiler->compiler.bugCount = compiler->script.bugCount; -#if !COMPILE_THREADED - compileScript(&compiler->compiler); -#endif + compileScript(&compiler->compiler, COMPILE_THREADED); compiler->result = TRUE; } else diff --git a/src/libraries/Runnr.c b/src/libraries/Runnr.c index 366c31a..e97fcee 100644 --- a/src/libraries/Runnr.c +++ b/src/libraries/Runnr.c @@ -471,12 +471,18 @@ static void _compileThread(void *data, Ecore_Thread *thread) printf("Can't create a new Lua state!\n"); } - ecore_thread_feedback(thread, compiler); + if (thread) + ecore_thread_feedback(thread, compiler); + else + _compileNotify(compiler, thread, NULL); } -void compileScript(LuaCompiler *compiler) +void compileScript(LuaCompiler *compiler, int threadIt) { - ecore_thread_feedback_run(_compileThread, _compileNotify, NULL, NULL, compiler, EINA_FALSE); + if (threadIt) + ecore_thread_feedback_run(_compileThread, _compileNotify, NULL, NULL, compiler, EINA_FALSE); + else + _compileThread(compiler, NULL); } // Assumes the scripts mutex is taken already. diff --git a/src/libraries/Runnr.h b/src/libraries/Runnr.h index f5f6960..8837eed 100644 --- a/src/libraries/Runnr.h +++ b/src/libraries/Runnr.h @@ -74,7 +74,7 @@ typedef struct script *scriptAdd(char *file, char *SID, RunnrServerCb send2server, void *data); -void compileScript(LuaCompiler *compiler); +void compileScript(LuaCompiler *compiler, int threadIt); void runScript(script *me); void resetScript(script *me); script *getScript(char *SID); -- cgit v1.1