diff options
-rw-r--r-- | externals/grill/flext/build.txt | 14 | ||||
-rw-r--r-- | externals/grill/flext/changes.txt | 1 | ||||
-rw-r--r-- | externals/grill/flext/flext.vcproj | 2 | ||||
-rwxr-xr-x | externals/grill/flext/source/flqueue.cpp | 13 | ||||
-rw-r--r-- | externals/grill/flext/source/flsupport.h | 5 | ||||
-rw-r--r-- | externals/grill/flext/source/flthr.cpp | 28 |
6 files changed, 34 insertions, 29 deletions
diff --git a/externals/grill/flext/build.txt b/externals/grill/flext/build.txt index 474b0698..92fdab7c 100644 --- a/externals/grill/flext/build.txt +++ b/externals/grill/flext/build.txt @@ -55,18 +55,18 @@ Useful combinations of the above are under Windows: pd msvc, using nmake -pd cygwin, using gnumake -pd mingw, using gnumake (from the CMD prompt, not msys!) +pd cygwin, using GNU make +pd mingw, using GNU make (from the CMD prompt, not msys!) max msvc, using nmake -max cygwin, using gnumake -max mingw, using gnumake (from the CMD prompt, not msys!) -pd bcc, using bmake +max cygwin, using GNU make +max mingw, using GNU make (from the CMD prompt, not msys!) +pd bcc, using Borland make under Linux or MacOSX: -pd gcc, using gnumake +pd gcc, using GNU make under MacOSX: -max gcc, using gnumake - Mach-O externals only (Max 4.5 upwards) +max gcc, using GNU make - Mach-O externals only (Max 4.5 upwards) There are two central scripts in the flext folder which invoke the building process: diff --git a/externals/grill/flext/changes.txt b/externals/grill/flext/changes.txt index 05dad4b0..b554af1e 100644 --- a/externals/grill/flext/changes.txt +++ b/externals/grill/flext/changes.txt @@ -21,6 +21,7 @@ Version history: - real class names now also reflect debug mode (like in flext_base_shared_d) - cleaned up internals (like Max/MSP typedefs) - fixed coexistence of message and signal objects in Max/MSP object libraries +- fixes for pthreads version 2 0.5.0: - fixes for 64 bit builds (size_t is integer type of pointer size) diff --git a/externals/grill/flext/flext.vcproj b/externals/grill/flext/flext.vcproj index d85667d0..a763ee7d 100644 --- a/externals/grill/flext/flext.vcproj +++ b/externals/grill/flext/flext.vcproj @@ -121,7 +121,7 @@ <Tool Name="VCCLCompilerTool" Optimization="0" - AdditionalIncludeDirectories="c:\programme\audio\pd-0.39-1\src;c:\data\prog\audio\sndobj\include;c:\data\prog\audio\stk\include" + AdditionalIncludeDirectories="c:\data\prog\packs\pthreads\include;c:\programme\audio\pd\src;c:\data\prog\audio\sndobj\include;c:\data\prog\audio\stk\include" PreprocessorDefinitions="WIN32;_DEBUG;_LIB;FLEXT_SYS_PD;FLEXT_THREADS;FLEXT_USE_SIMD;FLEXT_EXPORTS;xFLEXT_ATTRHIDE;xFLEXT_NOATTREDIT;_WIN32_WINNT=0x501" BasicRuntimeChecks="3" RuntimeLibrary="1" diff --git a/externals/grill/flext/source/flqueue.cpp b/externals/grill/flext/source/flqueue.cpp index a9077230..a83aa01e 100755 --- a/externals/grill/flext/source/flqueue.cpp +++ b/externals/grill/flext/source/flqueue.cpp @@ -23,9 +23,11 @@ WARRANTIES, see the file, "license.txt," in this distribution. #ifdef FLEXT_THREADS //! Thread id of message queue thread -flext::thrid_t flext::thrmsgid = 0; +flext::thrid_t flext::thrmsgid; #endif +static bool qustarted = false; + #ifdef FLEXT_SHARED /* For the shared version it _should_ be possible to have only one queue for all externals. @@ -299,6 +301,7 @@ static void Trigger() void flext_base::QWorker(thr_params *) { thrmsgid = GetThreadId(); + qustarted = true; for(;;) { qthrcond.Wait(); QWork(true); @@ -308,19 +311,19 @@ void flext_base::QWorker(thr_params *) void flext_base::StartQueue() { - static bool started = false; - if(started) return; - else started = true; - + if(qustarted) return; #if FLEXT_QMODE == 1 #ifdef PERMANENTIDLE sys_callback(QTick,NULL,0); + qustarted = true; #endif #elif FLEXT_QMODE == 2 LaunchThread(QWorker,NULL); + while(!qustarted) Sleep(0.001); #elif FLEXT_QMODE == 0 && (FLEXT_SYS == FLEXT_SYS_PD || FLEXT_SYS == FLEXT_SYS_MAX) // qclk = (t_qelem *)(qelem_new(NULL,(t_method)QTick)); qclk = (t_clock *)(clock_new(NULL,(t_method)QTick)); + qustarted = true; #else #error Not implemented! #endif diff --git a/externals/grill/flext/source/flsupport.h b/externals/grill/flext/source/flsupport.h index da9a19ae..87e198f8 100644 --- a/externals/grill/flext/source/flsupport.h +++ b/externals/grill/flext/source/flsupport.h @@ -17,6 +17,7 @@ WARRANTIES, see the file, "license.txt," in this distribution. #include "flstdc.h" #include <new> +#include <string.h> /*! \defgroup FLEXT_SUPPORT Flext support classes @{ @@ -828,12 +829,14 @@ protected: static thrid_t thrhelpid; static thrid_t thrmsgid; - static bool StartHelper(); static void ThrHelper(void *); //! the system's thread id static thrid_t thrid; // the system thread +private: + static bool StartHelper(); // used in flext::Setup() + public: /*! \brief Yield to other threads diff --git a/externals/grill/flext/source/flthr.cpp b/externals/grill/flext/source/flthr.cpp index e7e534eb..8f2a5966 100644 --- a/externals/grill/flext/source/flthr.cpp +++ b/externals/grill/flext/source/flthr.cpp @@ -38,11 +38,11 @@ WARRANTIES, see the file, "license.txt," in this distribution. #include <errno.h> -//! Thread id of system thread -flext::thrid_t flext::thrid = 0; +//! Thread id of system thread - will be initialized in flext::Setup +flext::thrid_t flext::thrid; -//! Thread id of helper thread -flext::thrid_t flext::thrhelpid = 0; +//! Thread id of helper thread - will be initialized in flext::Setup +flext::thrid_t flext::thrhelpid; //! \brief This represents an entry to the list of active method threads @@ -110,30 +110,26 @@ static void LaunchHelper(thr_entry *e) e->meth(e->params); } +bool initialized = false; //! Start helper thread bool flext::StartHelper() { - if(thrhelpid) return true; - - if(!thrid) { - // system thread has not been set - ERRINTERNAL(); - return false; - } - bool ok = false; + initialized = false; #if FLEXT_THREADS == FLEXT_THR_POSIX pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr,PTHREAD_CREATE_DETACHED); - ok = pthread_create (&thrhelpid,&attr,(void *(*)(void *))ThrHelper,NULL) == 0; + pthread_t tmp; + ok = pthread_create (&tmp,&attr,(void *(*)(void *))ThrHelper,NULL) == 0; #elif FLEXT_THREADS == FLEXT_THR_MP if(!MPLibraryIsLoaded()) error("Thread library is not loaded"); else { - OSStatus ret = MPCreateTask((TaskProc)ThrHelper,NULL,0,0,0,0,0,&thrhelpid); + MPTaskID tmp; + OSStatus ret = MPCreateTask((TaskProc)ThrHelper,NULL,0,0,0,0,0,&tmp); ok = ret == noErr; } #elif FLEXT_THREADS == FLEXT_THR_WIN32 @@ -145,7 +141,7 @@ bool flext::StartHelper() error("flext - Could not launch helper thread!"); else { // now we have to wait for thread helper to initialize - while(!thrhelpid || !thrhelpcond) Sleep(0.001); + while(!initialized) Sleep(0.001); // we are ready for threading now! } @@ -174,6 +170,8 @@ void flext::ThrHelper(void *) thrhelpcond = new ThrCond; + initialized = true; + // helper loop for(;;) { thrhelpcond->Wait(); |