File Coverage

blib/lib/Test/SharedObject/Lock.pm
Criterion Covered Total %
statement 20 20 100.0
branch 1 2 100.0
condition n/a
subroutine 7 7 100.0
pod 0 2 0.0
total 28 31 93.5


line stmt bran cond sub pod time code
1             package Test::SharedObject::Lock;
2 56     56   169 use strict;
  56         58  
  56         1519  
3 56     56   220 use warnings;
  56         56  
  56         903  
4 56     56   29416 use utf8;
  56         527  
  56         226  
5 56     56   1866 use Fcntl qw/:flock/;
  56         57  
  56         13747  
6              
7             sub new {
8 124     124 0 293 my ($class, $shared) = @_;
9 124 50       222984 open my $fh, '+<:raw', $shared->{file} or die "failed to open temporary file: $shared->{file}: $!"; # uncoverable branch
10 124         587512 flock $fh, LOCK_EX;
11 124         2469 return bless { fh => $fh } => $class;
12             }
13              
14 124     124 0 534 sub fh { shift->{fh} }
15              
16             sub DESTROY {
17 124     124   901 my $self = shift;
18 124         10293 flock $self->{fh}, LOCK_UN;
19 124         52618 close $self->{fh};
20             }
21              
22             1;
23             __END__