Re: [pygccxml-development] gil_guard_t example ?
Brought to you by:
mbaas,
roman_yakovenko
From: Damien F. <dam...@mo...> - 2008-08-19 13:19:08
|
Looking at the result that was what it looked it does but in one use of it in pyopensg there is those comments that miss lead me ... def unlocked_native(): ''' Returns a function transform creator for native functions and methods that do not hold the GIL while they execute. ''' this use a derived class from FT.transformer_t with : def required_headers(self): return [ pyplusplus.code_repository.gil_guard.file_name ] def __configureSealed(self, controller): # Create a guard for the GIL before the actual fucntion call is made. # This is an exception-safe approach to managing the GIL. controller.add_pre_call_code( 'pyplusplus::threading::gil_guard_t guard(true);' ) ..... so could I use the transformer to write a little wrapper that would do what I need ? static boost::python::object applyTo_0fec81cf95d5ecaac2dd1187f0efac01( ... .... ) { ::Muggins::MugginPtr result; { /// a object that wrapper the GIL unlocking scoped_releaseGIL(); /// my functiontion call result = inst.applyTo(target); } return bp::object( result ); } or some things like that ? Thanks Damien > On Tue, Aug 19, 2008 at 2:04 PM, Damien Fagnou > <dam...@mo...> wrote: > >> Hi , >> >> some of the member function that we bind can potentially take some time >> , and we are looking to a way to >> release the GIL during there execution . >> >> looking on the web I see that py++ as some things in place for that : >> gil_guard_t >> and I found couple of project using that , but I am still a little >> confuse on how to use it . >> > > gil_guard_t is used for completely other purposes. > > If you have algorithm, written in C++, which invokes code written in > Python, than you have to lock GIL. This is exactly what gil_guard_t > does. > > Not the opposite. > > >> is there an example somewhere on how to best use it ? >> > > No > > |