On Fri, Mar 6, 2009 at 11:48 AM, Sturla Molden <[email protected]> wrote:
> On 3/6/2009 7:23 AM, Greg Ewing wrote:
>
> There is also the simplified GIL API, which only requires two function
> calls. This is e.g. how ctypes makes sure the GIL is held in callbacks
> to Python.
>

Cython already used the simplified GIL API for pure-C functions
requiring GIL acquisition.

However, AFAIK the simplified GIL API does not suport multiple
interpreters, right?

Could we do it better?



> A 'with gil' block could just expand to:
>
> {
>    PyGILState_STATE _gilstate = PyGILState_Ensure();
>
>    /* now we have the GIL */
>
>    PyGILState_Release(_gilstate);
> }
>
> Nothing else is required. The simplified GIL API makes sure the function
> does not deadlock if the caller already has the GIL. The only
> requirement is that a call to PyGILState_Ensure should always have a
> matching call to PyGILState_Release.
>
>
>
> Sturla Molden
>
>
>
> _______________________________________________
> Cython-dev mailing list
> [email protected]
> http://codespeak.net/mailman/listinfo/cython-dev
>



-- 
Lisandro Dalcín
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594
_______________________________________________
Cython-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to