Driver/SpreadClient.pm

filter: Statementstmt 77.7% 7 / 9 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 83.3% 10 / 12 CC 1 SCAR 0.9
CC
1
Cov
78%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« Filter/SpreadClient.pm ↑ Summary Component/SpreadClient.pm »
1 #
2 # This file is part of POE-Component-SpreadClient
3 #
4 # This software is copyright (c) 2014 by Apocalypse.
5 #
6 # This is free software; you can redistribute it and/or modify it under
7 # the same terms as the Perl 5 programming language system itself.
8 #
9 2 ▶use strict; use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
10 package POE::Driver::SpreadClient;
11 $POE::Driver::SpreadClient::VERSION = '1.003';
12 our $AUTHORITY = 'cpan:APOCAL';
13  
14 # ABSTRACT: Implements the Spread driver for POE
15  
16 # Import some stuff
17 0 ▶use Spread;
Subroutine BEGIN: called CC=1 SCAR=2.6
18  
19 # magic number taken from Spread's MAX_READS
20 my $MAX_READS = 256;
21  
22 sub new {
23 my $type = shift;
24 my $mbox = shift;
25 my $self = bless \$mbox, $type;
26 return $self;
27 }
28  
29 sub get {
30 my $self = shift;
31  
32 my $reads_performed = 1;
33 my @buf;
34  
35 # read once:
36 push @buf, [ Spread::receive( $$self ) ];
37  
38 # Spread::poll returns 0 if no messages pending;
39 while( Spread::poll( $$self ) and ++$reads_performed <= $MAX_READS ) {
40 push @buf, [ Spread::receive( $$self ) ];
41 }
42  
43 return [ @buf ];
44 }
45  
46 1;
47  
48 __END__
« Filter/SpreadClient.pm ↑ Summary Component/SpreadClient.pm »