File Coverage

lib/Ubic/Lockf/Alarm.pm
Criterion Covered Total %
statement 6 16 37.5
branch 0 4 0.0
condition n/a
subroutine 2 4 50.0
pod 1 1 100.0
total 9 25 36.0


line stmt bran cond sub pod time code
1             package Ubic::Lockf::Alarm;
2             $Ubic::Lockf::Alarm::VERSION = '1.58_01'; # TRIAL
3 39     39   187 use strict;
  39         73  
  39         1213  
4 39     39   178 use warnings;
  39         60  
  39         6051  
5              
6             # ABSTRACT: alarm guard
7              
8             sub new ($$) {
9 0     0 1   my ($class, $timeout) = @_;
10 0           bless { 'alarm' => alarm($timeout), 'time' => time };
11             }
12              
13             sub DESTROY ($) {
14 0     0     my $self = shift;
15 0           local $@;
16 0           my $alarm;
17 0 0         if ($self->{alarm}) {
18 0           $alarm = $self->{alarm} + $self->{time} - time;
19 0 0         $alarm = 1 if $alarm <= 0;
20             } else {
21 0           $alarm = 0;
22             }
23 0           alarm($alarm);
24             }
25              
26             1;
27              
28             __END__