diff options
| author | Michael Vogt <michael.vogt@ubuntu.com> | 2009-07-02 12:46:30 +0200 |
|---|---|---|
| committer | Michael Vogt <michael.vogt@ubuntu.com> | 2009-07-02 12:46:30 +0200 |
| commit | 59b0a9ccf0b81a0a13ed10f4ceee28b24cfbb85c (patch) | |
| tree | a0fe8f134ca213575b1be037bfff8df146a08178 /python/progress.h | |
| parent | 1928a8fab432b219c6286ff08b142c57c6df5e6b (diff) | |
| parent | 4882fc138b9439469bb934f2db659bc97f131725 (diff) | |
| download | python-apt-59b0a9ccf0b81a0a13ed10f4ceee28b24cfbb85c.tar.gz | |
merged from sp
Diffstat (limited to 'python/progress.h')
| -rw-r--r-- | python/progress.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/python/progress.h b/python/progress.h index 5ac67b1c..29243bfc 100644 --- a/python/progress.h +++ b/python/progress.h @@ -15,10 +15,27 @@ #include <apt-pkg/cdrom.h> #include <Python.h> +/* PyCbObj_BEGIN_ALLOW_THREADS and PyCbObj_END_ALLOW_THREADS are sligthly + * modified versions of Py_BEGIN_ALLOW_THREADS and Py_END_ALLOW_THREADS. + * Instead of storing the thread state in a function-local variable these + * use a class attribute (with the same) name, allowing blocking and + * unblocking from different class methods. + * Py_BLOCK_THREADS and Py_UNBLOCK_THREADS do not define their own + * local variable but use the one provided by PyCbObj_BEGIN_ALLOW_THREADS + * and thus are the same as Py_BLOCK_THREADS and Py_UNBLOCK_THREADS. + */ +#define PyCbObj_BEGIN_ALLOW_THREADS \ + _save = PyEval_SaveThread(); +#define PyCbObj_END_ALLOW_THREADS \ + PyEval_RestoreThread(_save); \ + _save = NULL; +#define PyCbObj_BLOCK_THREADS Py_BLOCK_THREADS +#define PyCbObj_UNBLOCK_THREADS Py_UNBLOCK_THREADS class PyCallbackObj { protected: PyObject *callbackInst; + PyThreadState *_save; public: void setCallbackInst(PyObject *o) { |
