Parallol.pm untested

filter: Statementstmt 0.0% 0 / 12 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 2 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 17 CC 2 SCAR 15.4
CC
2
Cov
0%
do
6.0
BEGIN
2.0
CRAP 4.7
1 package Parallol;
2  
3 use Mojo::Base -base;
4  
5 our $VERSION = '0.3';
6  
7 has on_done => sub { sub { } };
8  
9 sub do {
10 my ($self, $callback) = @_;
11  
12 $self->{paralloling}++;
13  
14 sub {
15 $callback->(@_);
16 $self->on_done->($self) if --$self->{paralloling} == 0;
17 }
18 }
19  
20 "Parallolololololololololol";
21  
22 =head1 NAME
23  
24 Parallol - Because parallel requests should be as fun as parallololololol!
25  
26 =head1 SYNOPSIS
27  
28 my $p = Parallol->new;
29 my $ua = Mojo::UserAgent->new;
30  
31 my $titles = {};
32  
33 $p->on_done(sub {
34 say $titles;
35 });
36  
37 $ua->get('http://bbc.co.uk/', $p->do(sub {
38 $titles->{bbc} = pop->res->dom->at('title')->text;
39 }));
40  
41 $ua->get('http://mojolicio.us/', $p->do(sub {
42 $titles->{mojo} = pop->res->dom->at('title')->text;
43 }));
44  
45 =head1 DESCRIPTION
46  
47 Basic action for tracking parallel requests and running callbacks after
48 the last request completes. See L<Mojolicious::Plugin::Parallel> for a
49 more concrete implementation of this technique.
50  
51 =head1 METHODS
52  
53 =head2 do
54  
55 Wrap a request in a callback, and track parallel count.
56  
57 =head1 SEE ALSO
58  
59 L<Mojolicious>, L<Mojolicious::Plugin::Parallol>
60  
61 =head2 AUTHOR
62  
63 Magnus Holm L<mailto:magnus@nordaaker.com>
64  
65 =head2 LICENSE
66  
67 This software is licensed under the same terms as Perl itself.
68  
69 =cut