------ art_17052_19420690.1191868520780 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On 10/8/07, Roger Pack <rogerpack2005 / gmail.com> wrote: > > Roger Pack wrote: > >> I'm looking for some information about handling thread safety with > Ruby. > > > > Note also that sometimes if you are reading from TCPSockets the sockets > > get confused and start reading from one another. To avoid this (I > > think) use Francis Cianfrocca's EventMachine. > > > > Possible ways to fix this might (might) be to ensure that every socket > read/write is 'not at the same time as any other read/write' (i.e. > surrounded by a mutex lock), or to perhaps write a drop in replacement > for the TCPSocket class that just uses EventMachine in the background > for I/O and queues the input/output. In general, EventMachine encourages a style that doesn't use threads at all. The I/O queueing you're describing is already done by EM itself. All you have to do is write the handlers and EM will call them itself as the I/O comes in. It may seem impossible to write network-aware programs without threads. Not only is it possible but it can have very real benefits. ------ art_17052_19420690.1191868520780--