aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/py/source/main.h
diff options
context:
space:
mode:
authorThomas Grill <xovo@users.sourceforge.net>2004-06-21 14:08:57 +0000
committerThomas Grill <xovo@users.sourceforge.net>2004-06-21 14:08:57 +0000
commite728a5bc3db296b4b67c2d3e5b56558c42c566a8 (patch)
tree180656eeb13352bc2cee7fb759e2ff74332069d2 /externals/grill/py/source/main.h
parentcefab503b7db648244a4244ef255d15609e2c205 (diff)
""
svn path=/trunk/; revision=1826
Diffstat (limited to 'externals/grill/py/source/main.h')
-rw-r--r--externals/grill/py/source/main.h26
1 files changed, 16 insertions, 10 deletions
diff --git a/externals/grill/py/source/main.h b/externals/grill/py/source/main.h
index d6ca52cb..2e8419d3 100644
--- a/externals/grill/py/source/main.h
+++ b/externals/grill/py/source/main.h
@@ -50,6 +50,8 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#include "main.h"
+typedef std::map<flext::thrid_t,PyThreadState *> PyThrMap;
+
class py:
public flext_base
{
@@ -60,7 +62,7 @@ public:
~py();
static V lib_setup();
- static PyObject *MakePyArgs(const t_symbol *s,const AtomList &args,I inlet = -1,BL withself = false);
+ static PyObject *MakePyArgs(const t_symbol *s,int argc,const t_atom *argv,I inlet = -1,BL withself = false);
static AtomList *GetPyArgs(PyObject *pValue,PyObject **self = NULL);
protected:
@@ -74,7 +76,6 @@ protected:
PyObject *module,*dict; // inherited user class module and associated dictionary
- static I pyref;
static const C *py_doc;
V GetDir(PyObject *obj,AtomList &lst);
@@ -83,6 +84,7 @@ protected:
V AddToPath(const C *dir);
V SetArgs(I argc,const t_atom *argv);
V ImportModule(const C *name);
+ V UnimportModule();
V ReloadModule();
V Register(const C *reg);
@@ -124,16 +126,17 @@ protected:
V tick(V *);
public:
- static PyInterpreterState *pystate;
#ifdef FLEXT_THREADS
- static std::map<flext::thrid_t,PyThreadState *> pythrmap;
+ static PyInterpreterState *pystate;
+ static PyThreadState *pythrmain;
+ static PyThrMap pythrmap;
ThrMutex mutex;
- V Lock() { mutex.Unlock(); }
- V Unlock() { mutex.Unlock(); }
+ inline V Lock() { mutex.Unlock(); }
+ inline V Unlock() { mutex.Unlock(); }
#else
- V Lock() {}
- V Unlock() {}
+ inline V Lock() {}
+ inline V Unlock() {}
#endif
static PyObject* StdOut_Write(PyObject* Self, PyObject* Args);
@@ -152,11 +155,14 @@ protected:
#ifdef FLEXT_THREADS
+// if thread is not found in the thread map, the state of the system thread is used
+// we have yet to see if this has bad side-effects
+
#define PY_LOCK \
{ \
PyEval_AcquireLock(); \
- PyThreadState *__st = pythrmap[GetThreadId()]; \
- FLEXT_ASSERT(__st != NULL); \
+ PyThrMap::iterator it = pythrmap.find(GetThreadId()); \
+ PyThreadState *__st = it != pythrmap.end()?it->second:pythrmain; \
PyThreadState *__oldst = PyThreadState_Swap(__st);
#define PY_UNLOCK \