diff options
author | Thomas Grill <xovo@users.sourceforge.net> | 2005-03-14 04:58:13 +0000 |
---|---|---|
committer | Thomas Grill <xovo@users.sourceforge.net> | 2005-03-14 04:58:13 +0000 |
commit | 3e0446e7fda10c3d85a628b8c1effaa5bf7f5529 (patch) | |
tree | eac19e282f78a1d64759ca7dbeff02ee63d6a1d1 /externals/grill/py/source/main.h | |
parent | bf9523d0f232dc39ddf0b5d1985e93d431100c13 (diff) |
fixes for OSX
docs
optimizations and fixes
use optimized version
optimized function calls
adjust pd and py files for correct argument passing
more optimizations
svn path=/trunk/; revision=2627
Diffstat (limited to 'externals/grill/py/source/main.h')
-rw-r--r-- | externals/grill/py/source/main.h | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/externals/grill/py/source/main.h b/externals/grill/py/source/main.h index c76d43fa..f9df5807 100644 --- a/externals/grill/py/source/main.h +++ b/externals/grill/py/source/main.h @@ -92,8 +92,6 @@ protected: enum retval { nothing,atom,sequ }; - static PyObject *emptytuple; - // --- module stuff ----- static PyObject *module_obj,*module_dict; @@ -154,9 +152,12 @@ protected: void threadworker(); PyFifo qufifo; ThrCond qucond; + static PyThreadState *pythrsys; static PyThreadState *FindThreadState(); static void FreeThreadState(); +#else + static PyThreadState *FindThreadState() { return NULL; } #endif public: @@ -166,27 +167,35 @@ public: inline void Lock() { mutex.Unlock(); } inline void Unlock() { mutex.Unlock(); } - // this is respecially needed when one py/pyext object calls another one + // this is especially 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() + inline PyThreadState *PyLock(PyThreadState *st = FindThreadState()) { if(!IsSystemThread() || !lockcount++) PyEval_AcquireLock(); - return PyThreadState_Swap(FindThreadState()); + return PyThreadState_Swap(st); + } + + inline PyThreadState *PyLockSys() + { + if(!lockcount++) PyEval_AcquireLock(); + return PyThreadState_Swap(pythrsys); } inline void PyUnlock(PyThreadState *st) { - PyThreadState_Swap(st); - if(!IsSystemThread() || !--lockcount) PyEval_ReleaseLock(); + PyThreadState *old = PyThreadState_Swap(st); + if(old != pythrsys || !--lockcount) PyEval_ReleaseLock(); } + #else inline void Lock() {} inline void Unlock() {} - inline PyThreadState *PyLock() { return NULL; } + inline PyThreadState *PyLock(PyThreadState *) { return NULL; } + inline PyThreadState *PyLockSys() { return NULL; } inline void PyUnlock(PyThreadState *st) {} #endif |