AnyEvent-Net-Curl-Queued
view release on metacpan or search on metacpan
lib/AnyEvent/Net/Curl/Queued/Multi.pm view on Meta::CPAN
package AnyEvent::Net::Curl::Queued::Multi;
# ABSTRACT: Net::Curl::Multi wrapped by Moo
use strict;
use utf8;
use warnings qw(all);
use AnyEvent;
use Carp qw(confess);
use Moo;
use MooX::Types::MooseLike::Base qw(
AnyOf
ArrayRef
HashRef
Int
Num
Object
Ref
);
use Net::Curl::Multi;
use Scalar::Util qw(set_prototype);
# kill Net::Curl::Mulii prototypes as they wreck around/before/after method modifiers
set_prototype \&Net::Curl::Multi::new => undef;
set_prototype \&Net::Curl::Multi::socket_action => undef;
set_prototype \&Net::Curl::Multi::add_handle => undef;
extends 'Net::Curl::Multi';
has active => (is => 'ro', isa => Int, default => sub { -1 }, writer => 'set_active');
has pool => (is => 'ro', isa => HashRef[Ref], default => sub { {} });
has timer => (is => 'ro', isa => AnyOf[ArrayRef, Object], writer => 'set_timer', clearer => 'clear_timer', predicate => 'has_timer', weak_ref => 0);
has max => (is => 'ro', isa => Num, default => sub { 4 });
has timeout => (is => 'ro', isa => Num, default => sub { 60.0 });
our $VERSION = '0.049'; # VERSION
sub BUILD {
my ($self) = @_;
$self->setopt(Net::Curl::Multi::CURLMOPT_MAXCONNECTS => $self->max << 2);
$self->setopt(Net::Curl::Multi::CURLMOPT_SOCKETFUNCTION => \&_cb_socket);
$self->setopt(Net::Curl::Multi::CURLMOPT_TIMERFUNCTION => \&_cb_timer);
return;
}
## no critic (RequireArgUnpacking)
sub BUILDARGS { return $_[-1] }
# socket callback: will be called by curl any time events on some
# socket must be updated
sub _cb_socket {
my ($self, undef, $socket, $poll) = @_;
( run in 0.660 second using v1.01-cache-2.11-cpan-39bf76dae61 )