[ANN evdispatch]

Todd Fisher todd.fisher at gmail.com
Sat Apr 12 02:29:58 CEST 2008


On Fri, Apr 11, 2008 at 8:00 PM, Tony Arcieri <tony at medioh.com> wrote:

> On Fri, Apr 11, 2008 at 5:36 PM, Todd Fisher <todd.fisher at gmail.com>
> wrote:
>
> > I also really like to avoid multi-threading, but I'm afraid given the
> > limitation of the ruby language (not that it doesn't make up for them in
> > other ways) it's only possible to take full advantage of libev by running
> > it's event loop in a separate thread independent of ruby's own scheduling.
> >
>
> Both Rev (http://rev.rubyforge.org/) and Ebb (http://ebb.rubyforge.org/)
> run libev alongside Ruby 1.8's scheduler by effectively busy-waiting on
> rb_thread_schedule().  Rev also supports making long-running system calls
> with Ruby 1.9's new rb_thread_blocking_region().
>

You are correct.  It is possible to run the event loop in the main ruby
thread in both 1.8 and 1.9.  the limitation is perhaps less real then just
simply pragmatic.  If for example, I wanted to make use of other existing
libraries that are not streaming or eventful then I can only run them in a
straight line.  My example, is processing an ERB file with embedded
requests.  Normally, this would be done serially.  As the ERB document is
processed and a block like: <%= open("http://someaddress").read %> is
encountered all processing is blocked, until the request finishes.  If we
had a few dozen of these processing this single document could take
sometime.  I built evdispatch for  specifically this case.  So, before
processing the ERB if I know what URLs would normally be requested, I can
queue them all up to be requested in the background thread.  Then when the
ERB parser gets to the block that needs the response, it should already be
available and not block other requests while waiting. Now, how I get that
response back from the event loop thread, is where I think a syncrhonized
queue may not always be optimal and indeed on the ruby thread perhaps an
event loop may be more appropriate...  I actually used ebb as my test server
:-)

-Todd
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.schmorp.de/pipermail/libev/attachments/20080411/c9884f77/attachment.html>


More information about the libev mailing list