From: Francis Cianfrocca Date: 2006-05-04T01:49:59+09:00 Subject: Re: Multiplexed I/O ------=_Part_978_3322127.1146674995952 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline If you look at the implementation of Ruby's select, you'll see that it interacts with the Ruby-thread scheduler so as to solve the problem you're talking about. What's more interesting is that true native threads don't play nice in the sandbox with Ruby threads- they don't share synchronization primitives, and even worse, you can't call select(2) in a native thread because the Ruby scheduler uses it. If you do that, all Ruby threads will block. We wrote a native-code networking engine called eventmachine (available as = a Gem for Linux, Windows port coming very soon), that had to deal with these problems. Give it a look and see if it can help you. On 5/3/06, Eli Bendersky wrote: > > Minkoo Seo wrote: > > Robert Klemme wrote: > >> 2006/4/29, Vlad GALU : > >>> I'd like to use Ruby for a quite high performance networking tool= . > >>> In practice, writing a multithreaded C/C++ program is not pheasible > >>> due to the large connection pool I plan to manage, which would impose > >>> a very scarce stack size. From what I can see, Ruby's default I/O > >>> semantics are synchronous. One can opt for using IO#select though. > >>> Let's just say synchronous is OK, API-wise. My question is: if I use > >>> one (Ruby) thread per client, would it block the whole Ruby > >>> interpreter while performing blocking I/O ? > >> > >> No. You can have a multi threaded application that uses blocking IO > >> (interface wise) concurrently. > > > > I can't understand this. If ruby uses non native multithreading, then > > all threads will run in the same process. And that implies that one > > blocking I/O operation stop the all threads in the ruby interpreter > > process, doesn't it? > > > > This is indeed an interesting question, one that hasn't been cleared > enough in the Ruby docs, I feel. It seems that there's also a difference > between Windows and Unixes here. If someone could elaborate, it will be > great. > > -- > Posted via http://www.ruby-forum.com/. > > ------=_Part_978_3322127.1146674995952--