AnyEvent:HTTP::ACTIVE - but how many are events are running?

Marc Lehmann schmorp at schmorp.de
Thu Aug 25 17:03:09 CEST 2011


On Thu, Aug 25, 2011 at 05:14:51PM +0800, James Bromberger <james at rcpt.to> wrote:
> of currently running requests/", but what variable would expose the
> number of events that are (potentially) queued up?

One that is incremented each time a request is started and decremented
once it is finished.

> to complete. I'm trying to see if I can/should avoid threads (Perl
> 5.10).

Don't get confused by the terminology - "perl threads" aren't threads at
all, they are just the fork emulation of windows exposed on unix (and they
are not very portable). When in doubt, an explicit fork saves a lot of
resoruces and is much more portable.

> Is Coro recommended/preferred over spawning off a thread to deal with
> callback?

Well, yes, but coro threads do not run in parallel with each other, forked
processes do.

If the power of one cpu is enough for handling your requests, and you just
want to be able to linearly write down your handling code, OR part of the
7 seconds is not atcually spend on cpu but on e.g. I/O, then Coro will
allow you to do that.

> This would mean creating more events within my callback. Is this OK, or
> insane?

Thats OK, and in fact, the best way to do this kind of limiting.

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



More information about the anyevent mailing list