| 1 | package Seshat::Parallel; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use Data::Dumper; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | require Exporter; | ||||||||||
| 8 | require AutoLoader; | ||||||||||
| 9 | require Seshat; | ||||||||||
| 10 | |||||||||||
| 11 | |||||||||||
| 12 | @ISA = qw(Exporter AutoLoader); | ||||||||||
| 13 | # Items to export into callers namespace by default. Note: do not export | ||||||||||
| 14 | # names by default without a very good reason. Use EXPORT_OK instead. | ||||||||||
| 15 | # Do not simply export all your public functions/methods/constants. | ||||||||||
| 16 | @EXPORT = qw( | ||||||||||
| 17 | |||||||||||
| 18 | ); | ||||||||||
| 19 | $VERSION = '1.01'; | ||||||||||
| 20 | |||||||||||
| 21 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
| |||||||||||
| 22 | 0 | my ($classname,$files) = @_; | |||||||||
| 23 | 0 | my $self = {}; | |||||||||
| 24 | 0 | foreach (@$files) { | |||||||||
| 25 | 0 | $self->{files}->{$_} = Seshat->new($_); | |||||||||
| 26 | } | ||||||||||
| 27 | 0 | $self->{NAME} = "Seshat::Parallel"; | |||||||||
| 28 | 0 | bless ($self,$classname); | |||||||||
| 29 | 0 | return $self; | |||||||||
| 30 | } | ||||||||||
| 31 | 0 | ▶ | sub write { | ||||||||
|
Subroutine
write: not called CC=3 SCAR=24.8
| |||||||||||
| 32 | 0 | my ($self, $string, $flag) = @_; | |||||||||
| 33 | 0 | foreach ( keys %{$self->{files}} ) { | |||||||||
| 34 | 0 | my $lh = $self->{files}->{$_}; | |||||||||
| 35 | 0 | my $res = $lh->write($string,$flag); | |||||||||
| 36 | 0 | ▶ | warn "$@" unless $res; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 37 | } | ||||||||||
| 38 | } | ||||||||||
| 39 | 0 | ▶ | sub register { | ||||||||
|
Subroutine
register: not called CC=2 SCAR=17.9
| |||||||||||
| 40 | 0 | my ($self, $filename) = @_; | |||||||||
| 41 | 0 | ▶ | if (! exists $self->{files}->{$filename}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 42 | 0 | $self->{files}->{$filename} = Seshat->new($filename); | |||||||||
| 43 | } else { | ||||||||||
| 44 | 0 | $@ = "The requested file is already in queue"; | |||||||||
| 45 | 0 | return undef; | |||||||||
| 46 | } | ||||||||||
| 47 | 0 | return 1; | |||||||||
| 48 | } | ||||||||||
| 49 | 0 | ▶ | sub unregister { | ||||||||
|
Subroutine
unregister: not called CC=2 SCAR=17.9
| |||||||||||
| 50 | 0 | my ($self, $filename) = @_; | |||||||||
| 51 | 0 | ▶ | if (exists $self->{files}->{$filename}) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 52 | 0 | delete $self->{files}->{$filename}; | |||||||||
| 53 | } else { | ||||||||||
| 54 | 0 | $@ = "The requested file is not in queue"; | |||||||||
| 55 | 0 | return undef; | |||||||||
| 56 | } | ||||||||||
| 57 | 0 | return 1; | |||||||||
| 58 | } | ||||||||||
| 59 | |||||||||||
| 60 | 1; | ||||||||||
| 61 | __END__ | ||||||||||