[C++-sig] Threading support ?

Dave Hawkes daveh at cadlink.com
Mon Jun 17 05:09:02 CEST 2002


A useful facility in boost would be the ability for the user to 'plug-in'
code to support the Python GIL. Using the call policies precall/postcall
facilty would possibly be one way that this could be achieved when calling
c++ code from Python, though this is not ideal as it would be difficult to
make it exception proof. Also there is not similar support when calling from
c++ to python.

What I think is needed is a way of specifying a user defined class to be
defined inline with the call, much as the converter is in the code snippet
from boost below:

template<class R>
typename converter::return_from_python<R>::result_type
call(PyObject*callable,boost::type<R>* =0)
{
    converter::return_from_python<R>converter;
    return converter(
        PyEval_CallFunction(
            callable,const_cast<char*>("(" ")")));
}


In fact, by providing a specialised converter its constructor/destructor
could manage the GIL, but this is not really very practical.

Any ideas for supporting the GIL within boost, without adding overhead where
it's not needed?

Dave Hawkes












More information about the Cplusplus-sig mailing list