develooper Front page | perl.loop | Postings from December 2007

Re: Replacement of Event with EV

Thread Previous | Thread Next
From:
Marc Lehmann
Date:
December 5, 2007 17:19
Subject:
Re: Replacement of Event with EV
Message ID:
20071206011930.GA8531@schmorp.de
On Wed, Dec 05, 2007 at 05:40:47PM -0700, Rusty Conover <rconover@infogears.com> wrote:
> I'm looking into using EV rather then Event for my needs but it seems  
> the I/O timers don't have a nice way to schedule both a timeout and a  
> I/O callback at the same time into the same callback.

Thats a feature, and compared to Event, actually a bugfix.

> Such as setting the timeout parameter to the IO watcher.
> 
> Is this just my oversight or a design decision?

Its a design decision. Combining timers with io watchers is unnatural,
because:

- you often don't need both, so shouldn't be forced to pay for them
- you can't choose the type of timeout (event only has absolute timers
  anyways, though, which are unsuitable for many tasks such as idle timeouts
  for i/o, where you need relative timeouts).
- you have to manage two timeouts or weirder stuff when you have
  two separate i/o watchers, or use a third watcher (paying even more).
- it is often unclear on which events exactly the timeout gets reset
  (if at all), and even if not, there is no flexibility (how do you
  chose between an idle timeout and an overall timeout
  for completion with Event? you cannot).

As it is trivial to create a separate timeout (and much faster than with
Event, too), there is no drawback to this design.

It also usually leads to smaller and simpler code, once one understands
ones own needs...

-- 
                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_              http://www.deliantra.net
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      pcg@goof.com
      -=====/_/_//_/\_,_/ /_/\_\

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About