Nope, thats correct.
Basically :blocking => true in the Function options means the call
path looks like this:
ruby → ffi stub for parameter conversion → release GIL → call
actual native function → re-acquire GIL → ffi stub for result
conversion → return to ruby
Wheras without :blocking => true it is:
ruby → ffi stub for parameter conversion → actual native function →
ffi stub for result conversion-> return to ruby
Callbacks on the other hand always do this:
native code → ffi callback stub →
if thread.has_gil?
convert parameters to ruby
call ruby
convert result to native
elsif thread.is_ruby_thread?
acquire GIL
convert parameters to ruby
call ruby
convert result to native
release GIL
else # not a ruby thread - can’t call into ruby directly
bundle up ffi data
pass to ruby callback processing thread
wait for signal from callback processing thread
end
->native code
i.e. :blocking => true only affects ruby-to-native calls, and has no
effect on callbacks (i.e. native-to-ruby), since callbacks always
check for and acquire the GIL if needed.
Once you’re in a ruby callback (i.e. running ruby code), then you have
the GIL, and it will only be released again once you return from the
callback, or you call a native function that is marked as :blocking =>
true and it releases the GIL.
… and that is about the point your brain implodes. The JVM handles
all this nonsense in a much saner way.
On 14 May 2010 13:30, Chuck R. [email protected] wrote:
Looks good, apart from the bit about the blocking attribute and
and see).
On 11 May 2010 23:38, Chuck R. [email protected] wrote:
anything, since you don’t get original-object-return - you get an
LibZMQ.zmq_msg_data(@struct)), since that already returns a pointer.
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email