From f25cb430026b01219984364bb991948418909b77 Mon Sep 17 00:00:00 2001 From: Thomas Grill Date: Tue, 6 Dec 2005 21:52:26 +0000 Subject: fixed and cleaned up library related stuff, especially co-existance of Max message and DSP library objects fixes for pthreads version 2 more pthreads V2 fixes updated docs update docs updates for OSX svn path=/trunk/; revision=4155 --- externals/grill/flext/build.txt | 14 +++++++------- externals/grill/flext/changes.txt | 1 + externals/grill/flext/flext.vcproj | 2 +- externals/grill/flext/source/flqueue.cpp | 13 ++++++++----- externals/grill/flext/source/flsupport.h | 5 ++++- externals/grill/flext/source/flthr.cpp | 28 +++++++++++++--------------- 6 files changed, 34 insertions(+), 29 deletions(-) (limited to 'externals/grill/flext') 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 @@ +#include /*! \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 -//! 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(); -- cgit v1.2.1