You are viewing a plain text version of this content. The canonical link for it is here.
Posted to proton@qpid.apache.org by "Darryl L. Pierce" <dp...@redhat.com> on 2014/11/20 18:19:40 UTC

Ruby and blocking calls

There was a JIRA [1] opened recently concerning blocking calls in the
Ruby bindings, and asking for a means to release the global interpreter
lock for such calls.

The first issue to deal with is to provide a solution that would work on
both Ruby 1.8 and Ruby 1.9/2.0. In the latter case we have the
rb_thread_blocking_region() [2] Ruby API that can be used to mark a
method as blocking in order to release the GIL for a period of time.
However, there is no equivalent method in Ruby 1.8.

But what there is available in Ruby 1.8+ is the ability to wait on a
file descriptor. But this ability is also already exposed in the Ruby
bindings themselves using passive mode [3] to avoid the call to
Messenger.receive blocking the interpreter.

It strikes me that the solution should leverage the passive mode
capabilities of the underlying C code. After all, that's it's raison
d'etre, to make it possible in bindings to write non-blocking code code.

Thoughts? Ideas?

[1] http://issues.apache.org/jira/browse/PROTON-752
[2] http://tinyurl.com/naxtdfw
[3] http://issues.apache.org/jira/browse/PROTON-531

-- 
Darryl L. Pierce, Sr. Software Engineer @ Red Hat, Inc.
Delivering value year after year.
Red Hat ranks #1 in value among software vendors.
http://www.redhat.com/promo/vendor/