summaryrefslogtreecommitdiff
path: root/python/progress.h
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2009-07-30 15:55:55 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2009-07-30 15:55:55 +0200
commitde49263fd994bee687f4c2ceb7cd527f528f991b (patch)
tree2e43aec42673b960468d29d9a0c6b7ed9ea5ad1f /python/progress.h
parent2d5c6093e0d77576da867c2e5e6f42b6b75de37b (diff)
parent2215d046a10508c0d3950db6d924727b2a2db336 (diff)
downloadpython-apt-de49263fd994bee687f4c2ceb7cd527f528f991b.tar.gz
merged from mvo
Diffstat (limited to 'python/progress.h')
-rw-r--r--python/progress.h17
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) {