From 0bd834874c00c5fc5ed251c9fdbff68608d44eb5 Mon Sep 17 00:00:00 2001 From: Thomas Grill Date: Tue, 8 Mar 2005 04:59:25 +0000 Subject: pass timeout argument to stop method fixes for detached mode fixes for detached operation and single-threaded version use lock count instead of message queuing to avoid py->py messaging deadlock use new flext fifo svn path=/trunk/; revision=2602 --- externals/grill/py/source/main.h | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'externals/grill/py/source/main.h') diff --git a/externals/grill/py/source/main.h b/externals/grill/py/source/main.h index cd1c3736..2d495461 100644 --- a/externals/grill/py/source/main.h +++ b/externals/grill/py/source/main.h @@ -25,8 +25,8 @@ WARRANTIES, see the file, "license.txt," in this distribution. #define PYEXT_MODULE "pyext" // name for module #define PYEXT_CLASS "_class" // name for base class -#define PY_STOP_WAIT 1000 // ms -#define PY_STOP_TICK 10 // ms +#define PY_STOP_WAIT 100 // ms +#define PY_STOP_TICK 1 // ms @@ -50,6 +50,8 @@ public: ~py(); static void lib_setup(); + virtual void Exit(); + static PyObject *MakePyArgs(const t_symbol *s,int argc,const t_atom *argv,int inlet = -1,bool withself = false); static AtomList *GetPyArgs(PyObject *pValue,PyObject **self = NULL); @@ -109,14 +111,18 @@ protected: virtual void m_stop(int argc,const t_atom *argv); - bool shouldexit,respond; + bool respond; +#ifdef FLEXT_THREADS + bool shouldexit; int thrcount; int stoptick; Timer stoptmr; - int detach; void tick(void *); - +#endif + + int detach; + bool gencall(PyObject *fun,PyObject *args); virtual bool callpy(PyObject *fun,PyObject *args) = 0; @@ -153,18 +159,19 @@ public: // this is respecially needed when one py/pyext object calls another one // we don't want the message to be queued, but otoh we have to avoid deadlock + // (recursive calls can only happen in the system thread) static int lockcount; inline PyThreadState *PyLock() { - if(!lockcount++) PyEval_AcquireLock(); + if(!IsSystemThread() || !lockcount++) PyEval_AcquireLock(); return PyThreadState_Swap(FindThreadState()); } inline void PyUnlock(PyThreadState *st) { PyThreadState_Swap(st); - if(!--lockcount) PyEval_ReleaseLock(); + if(!IsSystemThread() || !--lockcount) PyEval_ReleaseLock(); } #else inline void Lock() {} @@ -189,9 +196,9 @@ protected: FLEXT_CALLBACK(m_dir) FLEXT_CALLGET_V(mg_dir) FLEXT_CALLBACK(m_doc) - FLEXT_CALLBACK_T(tick) #ifdef FLEXT_THREADS + FLEXT_CALLBACK_T(tick) FLEXT_THREAD(threadworker) #endif }; -- cgit v1.2.1