Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

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:

Hello
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
$cv->recv;,
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
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.

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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (9)
As of 2014-08-23 00:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (168 votes), past polls