Resolver/Mojo/IOLoop.pm untested

filter: Statementstmt 0.0% 0 / 27 Branchbran n/a Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 4 Podpod n/a totaltotal 0.0% 0 / 36 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 =head1 NAME
2  
3 Socket::More::Resolver::Mojo::IOLoop - Resover Mojo::IOLoop integration
4  
5 =head1 SYNOPSIS
6  
7 use Mojo::IOLoop;
8  
9 use Socket::More::Resolver;
10  
11 ...
12  
13 getaddrinfo...
14  
15 =head1 DESCRIPTION
16  
17 Built in driver for integrating L<Socket::More::Resolver> into the
18 L<Mojo::IOLoop>.
19  
20 If the event loop module is already in memory, it should automatically be
21 detected when useing L<Socket::More::Resolver>;
22  
23 =cut
24  
25 use warnings;
26 use strict;
27 package Socket::More::Resolver::Mojo::IOLoop;
28  
29 use IO::Handle;
30 use Mojo::IOLoop;
31  
32 # Circular reference to lexical scope variable.
33 my $circle=[];
34 my @watchers;
35 push @$circle, $circle, \@watchers;
36  
37 sub {
38  
39 # Use singleton loop if none specified
40 my $loop//=Mojo::IOLoop->singleton;
41 $Socket::More::Resolver::Shared=1;
42 # Code here to set up event handling on $loop that may be required
43 my @fh=Socket::More::Resolver::to_watch;
44 for(@fh){
45 my $fh=$_;
46 my $in_fd=fileno $fh;
47 my $w=IO::Handle->new_from_fd($in_fd, "r");
48 $loop->reactor->io($w, sub {
49 Socket::More::Resolver::process_results $in_fd;
50 }
51 )->watch($w, 1, 0);
52 push @watchers, $w;
53 }
54  
55  
56 # Add timer/monitor here
57 $loop->recurring(1, \&Socket::More::Resolver::monitor_workers);
58
59 # set clean up routine here
60 }
61  
62  
63