(CC'ing the dev list) On Wed, Jun 29, 2011 at 11:19:30AM -0400, Rajith Attapattu wrote: > Hey Darryl, > > (Please note it's not copied to the list) > > I am not a ruby expert, so maybe I am missing some context here. > > If an application calls a blocking method (ex sync() ) then the thread > that makes that call needs to be blocked until we get a result. > That calling thread maybe the main thread or another thread - but the > point is it should block.
I think the goal is that the call should wait for a response and then do some specific task. For that the Ruby way would be to pass in a lamda function that can be called after the blocking call completes. > But I got the feeling (from your description) that bcos of the > threading model in Ruby you can't have more than one thread ? > That is if a blocking call is involved then all threads (including the > main) gets blocked? Right. The problem that I'm hitting is that this blocking call brings the whole Ruby instance to a halt, which is a Bad Thing(tm). It would be better to have the ability to spin that call off on a separate thread _and_ call the lamdba function when completed. > Did I misunderstand you? Does ruby have green threads? (i.e one or > more ruby threads are managed by a single pthread underneath) You can have more than one thread. But in Ruby 1.8.x and lower you have the threading handled by Ruby itself: Ruby 1.9 will have pthreads. -- 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/
pgpZRHgVaKNCT.pgp
Description: PGP signature
