[zeromq-dev] Getting started with ruby bindings

Brian Candler B.Candler at pobox.com
Tue Apr 20 21:47:51 CEST 2010


On Wed, Apr 14, 2010 at 03:20:01PM +0100, Brian Candler wrote:
> What about in Ruby, given that Ruby (1.8) has
> only green threads, i.e. a single POSIX thread?

To answer my own question: rbzmq does _not_ play nicely with ruby 1.8
threads.  As soon as you call s.recv, it locks up the whole interpreter
until a message comes in.

This is because the ruby 1.8 interpreter is basically one big 'select' loop. 
C extensions are supposed to call rb_thread_select to pass control back to
the interpreter until a particular fd is ready for reading or writing - but
0mq provides a blocking C API.

ruby 1.9 may be different, because (as I understand it) it uses native
threads, albeit with a giant lock so that only one of them can run at once. 
But I don't use ruby 1.9 for other reasons.

So there may be a place for a pure-ruby implementation of zmq after all.

Regards,

Brian.



More information about the zeromq-dev mailing list