NAME

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

WARNING

this description is outdated

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 backends if you don't like the one detected:

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

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.

can_asynchdns

Will tell you whether libcurl has AsyncDNS capability.

warn_noasynchdns

Function used to warn about lack of AsynchDNS. You can overwrite it if you hate the warning.

{
    no warnings;
    # don't warn at all
    *Net::Curl::Simple::Async::warn_noasynchdns = sub ($) { };
}

Lack of AsynchDNS support in libcurl can severely reduce Net::Curl::Simple::Async efficiency. You should not disable the warning, just replace it with a method more suitable in your application.

BACKENDS

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

EV

Awesome and very efficient. Use it whenever you can.

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.

POE

Used under POE, only if no other backend could be detected. Slooow, avoid it. If you're using POE try POE::Loop::EV.

Select

Direct loop implementation using perl's builtin select. 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.