diff options
author | Thomas Grill <xovo@users.sourceforge.net> | 2002-12-05 05:36:32 +0000 |
---|---|---|
committer | Thomas Grill <xovo@users.sourceforge.net> | 2002-12-05 05:36:32 +0000 |
commit | 60ee6bb60b11bbfbccf56f335c9c6213e6daa79d (patch) | |
tree | 99b0c72c60aeba5d1a0489aae9edd16f371d965c /externals/grill/flext/source/flthr.cpp | |
parent | bbd9d289d152f6ef085dec680f0b1611c29f0e32 (diff) |
""
svn path=/trunk/; revision=278
Diffstat (limited to 'externals/grill/flext/source/flthr.cpp')
-rw-r--r-- | externals/grill/flext/source/flthr.cpp | 40 |
1 files changed, 13 insertions, 27 deletions
diff --git a/externals/grill/flext/source/flthr.cpp b/externals/grill/flext/source/flthr.cpp index 2a3ad3df..f23eb38f 100644 --- a/externals/grill/flext/source/flthr.cpp +++ b/externals/grill/flext/source/flthr.cpp @@ -12,25 +12,22 @@ WARRANTIES, see the file, "license.txt," in this distribution. \brief Implementation of the flext thread functionality. */ -#ifdef FLEXT_THREADS - #include "flext.h" #include "flinternal.h" -#ifdef MAXMSP -#define SCHEDTICK 1 -#endif +#ifdef FLEXT_THREADS -#ifdef NT +#if FLEXT_OS == FLEXT_OS_WIN #include <windows.h> #endif + #include <errno.h> bool flext_base::StartThread(void *(*meth)(thr_params *p),thr_params *p,char *methname) { static bool init = false; static pthread_attr_t attr; -#ifdef _DEBUG +#ifdef FLEXT_DEBUG if(!p) { ERRINTERNAL(); return false; @@ -55,8 +52,6 @@ bool flext_base::StartThread(void *(*meth)(thr_params *p),thr_params *p,char *me pthread_setschedparam(id,policy,&parm); } -// post("Create thread"); - pthread_t thrid; int ret = pthread_create (&thrid,&attr,(void *(*)(void *))meth,p); @@ -65,7 +60,7 @@ bool flext_base::StartThread(void *(*meth)(thr_params *p),thr_params *p,char *me pthread_setschedparam(id,policy,&parm); if(ret) { -#ifdef _DEBUG +#ifdef FLEXT_DEBUG error((char *)(ret == EAGAIN?"%s - Unsufficient resources to launch thread!":"%s - Could not launch method!"),methname); #endif error((char *)("%s - Could not launch method!"),methname); @@ -73,14 +68,8 @@ bool flext_base::StartThread(void *(*meth)(thr_params *p),thr_params *p,char *me delete p; return false; } - else { -#ifdef MAXMSP - sched_yield(); -#endif -// post("Create thread: OK"); - + else return true; - } } bool flext_base::PushThread() @@ -96,7 +85,7 @@ bool flext_base::PushThread() thrtail = nt; { -#ifdef NT +#if FLEXT_OS == FLEXT_OS_WIN // set detached thread to lower priority class DWORD err; HANDLE thr = GetCurrentThread(); @@ -128,9 +117,6 @@ bool flext_base::PushThread() tlmutex.Unlock(); -#ifdef MAXMSP - clock_delay(yclk,0); -#endif return true; } @@ -157,7 +143,7 @@ void flext_base::PopThread() delete ti; } else { -#ifdef _DEBUG +#ifdef FLEXT_DEBUG post("%s - INTERNAL ERROR: Thread not found!",thisName()); #endif } @@ -175,7 +161,7 @@ bool flext_base::ChangePriority(int dp,thrid_t id) sched_param parm; int policy; if(pthread_getschedparam(id,&policy,&parm) < 0) { -#ifdef _DEBUG +#ifdef FLEXT_DEBUG post("flext - failed to get parms"); #endif return false; @@ -183,7 +169,7 @@ bool flext_base::ChangePriority(int dp,thrid_t id) else { parm.sched_priority += dp; if(pthread_setschedparam(id,policy,&parm) < 0) { -#ifdef _DEBUG +#ifdef FLEXT_DEBUG post("flext - failed to change priority"); #endif return false; @@ -198,7 +184,7 @@ int flext_base::GetPriority(thrid_t id) sched_param parm; int policy; if(pthread_getschedparam(id,&policy,&parm) < 0) { -#ifdef _DEBUG +#ifdef FLEXT_DEBUG post("flext - failed to get parms"); #endif return -1; @@ -212,7 +198,7 @@ bool flext_base::SetPriority(int p,thrid_t id) sched_param parm; int policy; if(pthread_getschedparam(id,&policy,&parm) < 0) { -#ifdef _DEBUG +#ifdef FLEXT_DEBUG post("flext - failed to get parms"); #endif return false; @@ -220,7 +206,7 @@ bool flext_base::SetPriority(int p,thrid_t id) else { parm.sched_priority = p; if(pthread_setschedparam(id,policy,&parm) < 0) { -#ifdef _DEBUG +#ifdef FLEXT_DEBUG post("flext - failed to change priority"); #endif return false; |