line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Tie::Handle::Flock; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
24784
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
63
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
require Tie::Handle; |
7
|
|
|
|
|
|
|
our @ISA = qw(Tie::StdHandle); |
8
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
6
|
use Fcntl qw(:flock :seek); |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
379
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# WRITE this, scalar, length, offset |
13
|
|
|
|
|
|
|
sub WRITE { |
14
|
0
|
|
|
0
|
|
|
my $fh = shift; |
15
|
0
|
|
|
|
|
|
$fh->lock(); |
16
|
0
|
|
|
|
|
|
$fh->SUPER::WRITE( @_ ); |
17
|
0
|
|
|
|
|
|
$fh->unlock(); |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# PRINT this, LIST |
21
|
|
|
|
|
|
|
sub PRINT { |
22
|
0
|
|
|
0
|
|
|
my $fh = shift; |
23
|
0
|
|
|
|
|
|
$fh->lock(); |
24
|
0
|
|
|
|
|
|
$fh->SUPER::PRINT( @_ ); |
25
|
0
|
|
|
|
|
|
$fh->unlock(); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# PRINTF this, format, LIST |
29
|
|
|
|
|
|
|
sub PRINTF { |
30
|
0
|
|
|
0
|
|
|
my $fh = shift; |
31
|
0
|
|
|
|
|
|
$fh->lock(); |
32
|
0
|
|
|
|
|
|
$fh->SUPER::PRINTF( @_ ); |
33
|
0
|
|
|
|
|
|
$fh->unlock(); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub lock { |
37
|
0
|
|
|
0
|
1
|
|
my ($fh) = @_; |
38
|
0
|
|
|
|
|
|
flock($fh, LOCK_EX); |
39
|
0
|
|
|
|
|
|
seek( $fh, 0, SEEK_END ); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub unlock { |
43
|
0
|
|
|
0
|
1
|
|
my ($fh) = @_; |
44
|
0
|
|
|
|
|
|
flock($fh, LOCK_UN); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
__PACKAGE__; # End of Tie::Handle::Flock |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
__END__ |