| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package App::RemoteCommand::Select; |
|
2
|
1
|
|
|
1
|
|
11
|
use v5.24; |
|
|
1
|
|
|
|
|
2
|
|
|
3
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
52
|
|
|
4
|
1
|
|
|
1
|
|
13
|
use experimental qw(lexical_subs signatures); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
534
|
use IO::Select; |
|
|
1
|
|
|
|
|
1218
|
|
|
|
1
|
|
|
|
|
49
|
|
|
7
|
1
|
|
|
1
|
|
427
|
use App::RemoteCommand::LineBuffer; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
403
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
0
|
|
|
0
|
0
|
|
sub new ($class) { |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
10
|
0
|
|
|
|
|
|
bless { select => IO::Select->new, container => [] }, $class; |
|
11
|
|
|
|
|
|
|
} |
|
12
|
|
|
|
|
|
|
|
|
13
|
0
|
|
|
0
|
0
|
|
sub add ($self, %args) { |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
14
|
0
|
|
|
|
|
|
my $pid = $args{pid}; |
|
15
|
0
|
|
|
|
|
|
my $fh = $args{fh}; |
|
16
|
0
|
|
|
|
|
|
my $host = $args{host}; |
|
17
|
0
|
|
0
|
|
|
|
my $buffer = $args{buffer} || App::RemoteCommand::LineBuffer->new; |
|
18
|
|
|
|
|
|
|
push $self->{container}->@*, { |
|
19
|
0
|
|
|
|
|
|
pid => $pid, |
|
20
|
|
|
|
|
|
|
fh => $fh, |
|
21
|
|
|
|
|
|
|
host => $host, |
|
22
|
|
|
|
|
|
|
buffer => $buffer, |
|
23
|
|
|
|
|
|
|
}; |
|
24
|
0
|
|
|
|
|
|
$self->{select}->add($fh); |
|
25
|
|
|
|
|
|
|
} |
|
26
|
|
|
|
|
|
|
|
|
27
|
0
|
|
|
0
|
0
|
|
sub can_read ($self, @args) { |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
my @fh = $self->{select}->can_read(@args); |
|
29
|
0
|
|
|
|
|
|
my @ready; |
|
30
|
0
|
|
|
|
|
|
for my $c ($self->{container}->@*) { |
|
31
|
0
|
0
|
|
|
|
|
if (grep { $c->{fh} == $_ } @fh) { |
|
|
0
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
push @ready, $c; |
|
33
|
|
|
|
|
|
|
} |
|
34
|
|
|
|
|
|
|
} |
|
35
|
0
|
|
|
|
|
|
return @ready; |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
|
|
38
|
0
|
|
|
0
|
0
|
|
sub count ($self) { |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
$self->{select}->count; |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
0
|
|
|
0
|
0
|
|
sub remove ($self, $kind, $value) { |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
for my $i (0..$self->{container}->$#*) { |
|
44
|
0
|
0
|
|
|
|
|
if ($self->{container}[$i]{$kind} eq $value) { |
|
45
|
0
|
|
|
|
|
|
my $remove = splice $self->{container}->@*, $i, 1; |
|
46
|
0
|
|
|
|
|
|
$self->{select}->remove($remove->{fh}); |
|
47
|
0
|
|
|
|
|
|
return $remove; |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
} |
|
50
|
0
|
|
|
|
|
|
return; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |