line |
l |
!l |
condition |
51
|
0 |
1 |
$_sweeper //= sub {
my $i = 0;
my $entry;
my $closer = $self->closer;
foreach $_ (keys %_cache) {
$entry = $_cache{$_};
&$closer($entry) if $entry->[4] == 1;
last if ++$i >= $_sweep_size;
};
}
|
65
|
3 |
2 |
$mode //= 0 |
117
|
4 |
1 |
$_opener //= sub {
my($key_path, $mode, $force) = @_;
my $in_fd;
my $existing_entry = $_cache{$key_path};
$mode //= 0;
if (not $existing_entry or $force) {
'???';
my(@stat) = stat $key_path;
unless (@stat and -f _) {
&$_closer($existing_entry, 1) if $existing_entry;
return undef;
};
my @entry;
$in_fd = POSIX::open($key_path, $mode);
if (defined $in_fd) {
if ($existing_entry) {
POSIX::dup2($in_fd, $existing_entry->[1]);
POSIX::close($in_fd);
@{$$existing_entry[3]} = @stat;
}
else {
CORE::open $entry[2], "+<&=$in_fd" unless $_no_fh;
$entry[3] = \@stat;
$entry[0] = $key_path;
$entry[1] = $in_fd;
$entry[4] = 1;
$existing_entry = \@entry;
$_cache{$key_path} = $existing_entry if $_enabled;
};
}
else {
'???';
};
};
++$existing_entry->[4] if $existing_entry;
$existing_entry;
}
|
150
|
2 |
1 |
$_closer //= sub {
my $entry = $_[0];
if (--$entry->[4] <= 0 or $_[1]) {
my $actual = delete $_cache{$entry->[0]};
if ($actual) {
$actual->[4] = 0;
POSIX::close($actual->[1]);
$actual->[2] = undef;
}
else {
die "Entry does not exist";
};
};
}
|
161
|
0 |
1 |
$_updater //= sub {
@{$_[0][3]} = stat $_[0][0];
unless (@{$_[0][3]} and -f _) {
&$_closer($_[0], 1);
};
}
|