From 0cb3e6d4c8d3e2d3b0ed3951e3bd46eee49d25e8 Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Sun, 12 Oct 2014 14:11:03 +0200 Subject: [PATCH] libpython: a few more opportunities for releasing the GIL --- src/libpython/core.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/libpython/core.cpp b/src/libpython/core.cpp index 62890f4a..cbe0ff07 100644 --- a/src/libpython/core.cpp +++ b/src/libpython/core.cpp @@ -197,6 +197,16 @@ struct TSpectrum_to_Spectrum { } }; +static void scheduler_cancel(Scheduler *scheduler, ParallelProcess *proc) { + ReleaseGIL gil; + scheduler->cancel(proc); +} + +static void scheduler_wait(Scheduler *scheduler, const ParallelProcess *proc) { + ReleaseGIL gil; + scheduler->wait(proc); +} + static Matrix4x4 *Matrix4x4_fromList(bp::list list) { if (bp::len(list) == 4) { Float buf[4][4]; @@ -1769,10 +1779,9 @@ void export_core() { bp::class_("SerializableObjectVector") .def(bp::vector_indexing_suite()); - bool (Scheduler::*scheduler_cancel)(ParallelProcess *)= &Scheduler::cancel; BP_CLASS(Scheduler, Object, bp::no_init) .def("schedule", &Scheduler::schedule) - .def("wait", &Scheduler::wait) + .def("wait", scheduler_wait) .def("cancel", scheduler_cancel) .def("registerResource", &Scheduler::registerResource) .def("registerMultiResource", &Scheduler::registerMultiResource)