27 Mar 2012, 09:13
Zeno_surf_pragsmall

Zeno Davatz (4 posts)

Hi

Can you please make an example of what you mean by the “calling ruby Thread” on page 169.

bq. The truth is that it is only the calling Ruby thread that gets blocked during the long system calls, and other Ruby threads will run without any problems.

Thanks! Great book!

27 Mar 2012, 21:57
Generic-user-small

Makoto Inoue (9 posts)

Hi, Thank you for your comment.

I may not have translated properly. What I meant by in this sentence is that one thread call does not block other threads if they are IO or system calls (not CPU related). That’s why the following “sleep” example takes 3 seconds to run 3 jobs each of which takes 3 seconds. If they block each other, it would have taken 9 seconds.

In other words, Ruby’s Thread can handle tasks in parallel as long as they are not CPU related. In this sense, it’s concurrency capability is similar to evented libraries (see https://gist.github.com/1498215), though evented can handle more connections.

Hope this explains a bit better.

  You must be logged in to comment