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 you use WWW::CurlOO::Simple::Async your WWW::CurlOO::Simple objects will no longer block.

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. However, you may force some backend if you don't like the one detected:

use Irssi;
# Irssi backend would be picked
use WWW::CurlOO::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 (WWW::CurlOO::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

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.