Right - for operations that you don't want to handle inside a single tick
(long running stuff), EventMachine can farm off to another thread so you
don't block the event thread.  When you're handling I/O and not doing any
CPU intensive operations, you don't need to use defer. It's been a while
since I've used EventMachine, but that's my take on it.

On 2 December 2011 16:26, Dave Newman <ddanger...@gmail.com> wrote:

>  I think by default it keeps 10 threads around for running async
> operations.
>
> Dave Newman
> @whatupdave
>
>  On Friday, 2 December 2011 at 4:09 PM, Dmytrii Nagirniak wrote:
>
> On 02/12/2011, at 3:47 PM, freshto...@gmail.com wrote:
>
>
> Hi Dmytrii,
>
> On 2 December 2011 15:37, Dmytrii Nagirniak <dna...@gmail.com> wrote:
>
>
> On 02/12/2011, at 3:16 PM, Dave Newman wrote:
>
> > You could use eventmachine.
> >
>
> EM uses Threads under the hood. So it's doesn't seem to be cheap.
>
>
> No - it works like node.js.  It uses event-driven I/O based on epoll,
> which is similar to libev (what node.js uses). It's fast (for Ruby) and
> cheap.  Anything you can do in node.js you can do with EventMachine,
> libraries permitting.
>
>
> Hmm. Interesting. The docs say that it does use threads internally:
>
> The action of 
> defer<http://eventmachine.rubyforge.org/EventMachine.html#M000486> is
> to take the block specified in the first parameter (the “operation”) and
> schedule it for asynchronous execution on an internal thread pool
> maintained by 
> EventMachine<http://eventmachine.rubyforge.org/EventMachine.html>
> .
>
> But I guess it should indeed be cheap enough with the internal thread pool.
>
> Thanks.
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Ruby or Rails Oceania" group.
> To post to this group, send email to rails-oceania@googlegroups.com.
> To unsubscribe from this group, send email to
> rails-oceania+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/rails-oceania?hl=en.
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Ruby or Rails Oceania" group.
> To post to this group, send email to rails-oceania@googlegroups.com.
> To unsubscribe from this group, send email to
> rails-oceania+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/rails-oceania?hl=en.
>



-- 
James

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
or Rails Oceania" group.
To post to this group, send email to rails-oceania@googlegroups.com.
To unsubscribe from this group, send email to 
rails-oceania+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rails-oceania?hl=en.

Reply via email to