RPC/ToWorker/Callback.pm untested

filter: Statementstmt 0.0% 0 / 35 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 57 CC 6 SCAR 32.6
CC
6
Cov
0%
master_call
42.0
BEGIN
2.0
BEGIN
2.0
CRAP 26.0
1  
2 package RPC::ToWorker::Callback;
3  
4 use strict;
5 use warnings;
6 require Exporter;
7 use Storable qw(freeze thaw);
8  
9 our @EXPORT = qw(master_call);
10 our @ISA = qw(Exporter);
11  
12 our $master;
13  
14 sub master_call
15 {
16 my ($packages, $func, $with, @args) = @_;
17  
18 local($0) = $0;
19  
20 $0 =~ s/: RUNNING/: making RPC call on master to $func/g;
21  
22 my $pkgs = ref($packages)
23 ? $packages
24 : [ split(' ', $packages) ];
25 $with = ref($with)
26 ? $with
27 : [ split(' ', $with) ];
28  
29 my $args = freeze(\@args);
30 printf $master "DATA %d CALL %s with %s after loading %s\n%s", length($args), $func, "@$with", "@$pkgs", $args
31 or die "print to master: $!";
32  
33 die if $func =~ /\s/;
34 die unless $func =~ /\S/;
35  
36 my $ds =<$master>;
37 die unless $ds =~ /^DATA (\d+) DONE_RESPONSE\n/;
38 my $amt = $1;
39 my $buf = '';
40 while (length($buf) < $amt) {
41 read($master, $buf, $amt - length($buf), length($buf)) or die;
42 }
43 my $ret = thaw($buf);
44 return @$ret;
45 }
46  
47 1;
48  
49 __END__