Test-SharedObject
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/Test/SharedObject/Lock.pm view on Meta::CPAN
package Test::SharedObject::Lock;
use strict;
use warnings;
use utf8;
use Fcntl qw/:flock/;
sub new {
my ($class, $shared) = @_;
open my $fh, '+<:raw', $shared->{file} or die "failed to open temporary file: $shared->{file}: $!"; # uncoverable branch
flock $fh, LOCK_EX;
return bless { fh => $fh } => $class;
}
sub fh { shift->{fh} }
sub DESTROY {
my $self = shift;
flock $self->{fh}, LOCK_UN;
close $self->{fh};
}
view all matches for this distributionview release on metacpan - search on metacpan
( run in 1.686 second using v1.00-cache-2.02-grep-82fe00e-cpan-d29e8ade9f55 )