aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/flext/source/flthr.cpp
diff options
context:
space:
mode:
authorThomas Grill <xovo@users.sourceforge.net>2005-12-06 21:52:26 +0000
committerThomas Grill <xovo@users.sourceforge.net>2005-12-06 21:52:26 +0000
commitf25cb430026b01219984364bb991948418909b77 (patch)
treed95631e8288966235e180754742d53ebbe0c8c01 /externals/grill/flext/source/flthr.cpp
parent8c29affcbda72a462c0fd10d77da1b139a6a438d (diff)
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
Diffstat (limited to 'externals/grill/flext/source/flthr.cpp')
-rw-r--r--externals/grill/flext/source/flthr.cpp28
1 files changed, 13 insertions, 15 deletions
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();