NAME
WWW::CurlOO::Simple::Async - perform WWW::CurlOO requests asynchronously
SYNOPSIS
use WWW::CurlOO::Simple;
use WWW::CurlOO::Simple::Async;
# this does not block now
WWW::CurlOO::Simple->new()->get( $uri, \&finished );
WWW::CurlOO::Simple->new()->get( $uri2, \&finished );
# block until all requests are finished, may not be needed
WWW::CurlOO::Simple::Async::loop();
sub finished
{
my ( $curl, $result ) = @_;
print "document body: $curl->{body}\n";
}
DESCRIPTION
If your code is using WWW::CurlOO::Simple correctly (that is - processing any finished requests in callbacks), the only change needed to add asynchronous support is adding:
use WWW::CurlOO::Simple::Async;
It will pick up best Async backend automatically but you may force it if you don't like the one detected:
use Irssi;
# Irssi backend would be picked
use WWW::CurlOO::Simple::Async qw(AnyEvent);
FUNCTIONS
- loop
-
Block until all requests are complete. Some backends may not support it.
BACKENDS
In order of preference.
- Irssi
-
Will be used if Irssi has been loaded. Does not support loop() - it will not block.
- AnyEvent
-
Will be used if AnyEvent has been loaded. There should be no need to use loop() but it should work in most cases.
- Perl
-
Direct loop implementation in perl. Will be used if no other backend has been found. You must call loop() to get anything done.
SEE ALSO
WWW::CurlOO::Simple::UserAgent WWW::CurlOO::Simple::Async WWW::CurlOO::Easy
COPYRIGHT
Copyright (c) 2011 Przemyslaw Iskra <sparky at pld-linux.org>.
This program is free software; you can redistribute it and/or modify it under the same terms as perl itself.