NAME

Net::Curl::Simple::Async - perform Net::Curl requests asynchronously

SYNOPSIS

use Net::Curl::Simple;
use Net::Curl::Simple::Async;

# this does not block now
Net::Curl::Simple->new()->get( $uri, \&finished );
Net::Curl::Simple->new()->get( $uri2, \&finished );

# block until all requests are finished, may not be needed
Net::Curl::Simple::Async::loop();

sub finished
{
    my ( $curl, $result ) = @_;
    print "document body: $curl->{body}\n";
}

DESCRIPTION

If you use Net::Curl::Simple::Async your Net::Curl::Simple objects will no longer block.

If your code is using Net::Curl::Simple correctly (that is - processing any finished requests in callbacks), the only change needed to add asynchronous support is adding:

use Net::Curl::Simple::Async;

It will pick up best Async backend automatically. However, you may force some backend if you don't like the one detected:

use Irssi;
# Irssi backend would be picked
use Net::Curl::Simple::Async qw(AnyEvent);

You may need to call loop() function if your code does not provide any suitable looping mechanism.

FUNCTIONS

loop

Block until all requests are complete. Some backends may not support it. Most backends don't need it.

BACKENDS

In order of preference (Net::Curl::Simple::Async will try them it that order):

Irssi

Will be used if Irssi has been loaded. Does not support loop(), the function will issue a warning and won't block.

AnyEvent

Will be used if AnyEvent has been loaded. In most cases you will already have a looping mechanism on your own, but you can call loop() if you don't need anything better.

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

Net::Curl::Simple::UserAgent Net::Curl::Simple::Async Net::Curl::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.