Re: [Quickfix-developers] QuickFIX Python and Twisted
Brought to you by:
orenmnero
|
From: Oren M. <or...@qu...> - 2006-11-15 23:23:41
|
We should be able to use Py_BLOCK_THREADS and Py_UNBLOCK_THREADS.
The _save variable will need to be global and protected.
--oren
On Nov 15, 2006, at 5:15 PM, Robert Parrott wrote:
> BTW, looking at these macro definitions, it isn't as easy as inserting
> the macros directly, since there are defined to be used in pairs,
> before and after. Instead, for the callbacks there will need to be
> either explicit code or new macros:
>
> (from ceval.h of python 2.3 )
>
> PyAPI_FUNC(void) PyEval_InitThreads(void);
> PyAPI_FUNC(void) PyEval_AcquireLock(void);
> PyAPI_FUNC(void) PyEval_ReleaseLock(void);
> PyAPI_FUNC(void) PyEval_AcquireThread(PyThreadState *tstate);
> PyAPI_FUNC(void) PyEval_ReleaseThread(PyThreadState *tstate);
> PyAPI_FUNC(void) PyEval_ReInitThreads(void);
>
> #define Py_BEGIN_ALLOW_THREADS { \
> PyThreadState *_save; \
> _save = PyEval_SaveThread();
> #define Py_BLOCK_THREADS PyEval_RestoreThread(_save);
> #define Py_UNBLOCK_THREADS _save = PyEval_SaveThread();
> #define Py_END_ALLOW_THREADS PyEval_RestoreThread(_save); \
> }
|