If it should be of interest to anyone I've created this simple functional example;
FruitJuicer to demonstrate wrapping a C++ class with Cython.
Amongst other things it demonstrates callbacks and bidirectional passing of a Python list to a std::vector<std::string> and executing a callback from a different C++ thread.
Though it's not directly on topic for the Cython mailing list; does anyone know how the Python Global Interpreter Lock (GIL) can be acquired and released from WITHIN a C++ thread? I.e. in this case from FruitJuicer;
//Runs in a thread and performs callback to Python passing std::vector<std::string> to be converted to a Python list.
void run_juicer()
{
AcquireGILHere()
pyVectorFunction(fruits, usrData);
ReleaseGILHere()
count += fruits.size();//keep count
}
Ultimately I intend to use this pattern with a long running thread and would not want to hold the GIL indefinitely, just when there is Python work to do.
Thanks,
Gofaster