News for hackers. Stuff that matters.
Re:EventMachine: scalable non-blocking i/o in ruby by tptacek on Monday March 15, 2010 @04:14PM (#1193966)
Maybe, but part of the value of async programming is never having to thread, so none of this really lights me up.
Re:EventMachine: scalable non-blocking i/o in ruby by jrockway on Monday March 15, 2010 @06:23PM (#1194308)
Coro basically allows you to write:

   foo();
   bar();
instead of:

   foo( cb => sub { bar() } );
 
Behind the scenes, it's basically the same thing. It's cooperative so your code does not get preempted where you don't want it to be; the locking is implicit.

But you can switch to preemption and explicit locking if you desire. At that point, IMO, it's time to ditch Perl / Python / Ruby and use a language with a sane STM implementation, because locks suck.

Re:EventMachine: scalable non-blocking i/o in ruby by BrianHammond on Monday March 15, 2010 @05:01PM (#1194108)
Honest question: is there a purely event-driven I/O framework (no threads anywhere)?

The one that a lot of people have gotten excited about recently is Node.js and that uses threads for file I/O (libeio).

Re:EventMachine: scalable non-blocking i/o in ruby by jrockway on Monday March 15, 2010 @06:49PM (#1194361)
What you you think a "thread" is? A thread of execution? An OS thread? A lightweight thread?

Without defining thread, your question is pretty close to meaningless.

Re:EventMachine: scalable non-blocking i/o in ruby by WALoeIII on Monday March 15, 2010 @06:15PM (#1194290)
http://github.com/lifo/cramp

It works best in Thin (EventMachine) or Rainbows! (Fibers).

If you are doing I/O you should use NeverBlock (http://www.espace.com.eg/neverblock/) they've even implemented a MySQL driver, the best part is they're 'drop-in' so you don't have to learn a new API, they just hide the async calls from you.

Fibers I think are closer to Erlang style than the event loop, and much more straight forward to program.

Re:EventMachine: scalable non-blocking i/o in ruby by jemfinch on Monday March 15, 2010 @05:35PM (#1194195)
> Honest question: is there a purely event-driven I/O framework (no threads anywhere)?

You might look into a continuation-based framework. With continuations, you can do purely event-driven IO written in a direct style: the framework can grab the "callback" itself by snagging the continuation of its slow IO functions.

You still run into the same problems with blocking (non-IO, or non-framework) code taking up more than its fair share of time, however.

Re:EventMachine: scalable non-blocking i/o in ruby by tptacek on Monday March 15, 2010 @05:05PM (#1194118)
EventMachine doesn't thread unless you ask it to. I use EventMachine in Ruby and libevent in C with nary a mutex in sight.
Re:EventMachine: scalable non-blocking i/o in ruby by BrianHammond on Monday March 15, 2010 @06:01PM (#1194261)
I see. My (wrong) understanding was that EM used a thread pool to do file I/O like Node.js. It appears to add the file descriptor to the event loop's watch list.