Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Using AnyEvent

by 0day (Sexton)
on May 17, 2012 at 10:08 UTC ( #971025=perlquestion: print w/ replies, xml ) Need Help??
0day has asked for the wisdom of the Perl Monks concerning the following question:

I have a question on the use of AE (HTTP).

At the beginning of the code, I create an object
my $cv = AnyEvent->condvar;
Next, I adds a few tasks in the processing (urls), and then call the
which blocks the thread.
Tasks are executed asynchronously, but one unfulfilled task blocks execution of the program.
Is it possible to make a non-block call to $ cv-> recv (with timeout) and ask it in a loop, like a poll / epoll?

Very thanks.
Sorry for my english.

Comment on Using AnyEvent
Select or Download Code
Replies are listed 'Best First'.
Re: Using AnyEvent
by zentara (Archbishop) on May 17, 2012 at 19:52 UTC
    Since no one else has answered yet; :-)

    I'm not an expert on AnyEvent, or exactly what $cv->recv is supposed to be reading, but in general, you use sysread in an select loop to avoid blocking. Look at AnyEvent::Handle for example. It uses sysread but it hides it in the module. Also see AnyEvent for I/O events for a good example.

    It would help if you posted a working code example.

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh
Re: Using AE
by Anonymous Monk on May 17, 2012 at 11:13 UTC
    Unless AE is a well-known acronym for AnyEvent please change the title to be AnyEvent so that the thread can be more-easily found in the future.

      Also see AE, which is a remodeling of AnyEvent with a slightly different API.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://971025]
Approved by marto
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (9)
As of 2015-11-30 10:48 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (769 votes), past polls