From: Daniel Bush Date: 2009-10-21T08:26:26+09:00 Subject: Re: ruby 1.8.6, threadpooling and blocking sockets - advice/help Robert Klemme wrote: > On 20.10.2009 02:31, Daniel Bush wrote: >>>> @socket.bind( @sockaddr ) >> Ok, I wasn't sure if it was appropriate having >1 thread per socket >> addition; I wasn't sure. >> >> I guess I'll have to scupper that idea or exhaustively test it to prove >> it works and has benefit - both of which are questionable at this point. > > Frankly, I wouldn't invest that effort: every example in all programming > languages I have seen has just a single acceptor thread. Accepting > socket connections is not an expensive operation so as long as you > refrain from further processing a single thread is completely sufficient > for handling accepts. > >> >>> >>> end >>> queue.enq client >> I am scratching my head a little with this line: >> until (cl = q.deq).equal? q >> >> I'm familiar with Queue and its behaviour. > > That's the worker thread termination code which basically works by > checking whether the item fetched from the Queue is the Queue instance > itself. Actually I omitted the other half of the code (the place which > puts all those q instances in itself) because I didn't want to make the > code more complex and also termination condition was unknown (may be a > signal, a number of handled connections etc.). > Ok, that's cool. I was pushing termination jobs on the thing I was playing with although what you're doing there might be cleaner! Thanks for the advice. Cheers, Daniel Bush -- Posted via http://www.ruby-forum.com/.