| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package IO::Busy; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
23178
|
use version; $VERSION = qv('0.0.3'); |
|
|
1
|
|
|
|
|
3454
|
|
|
|
1
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
98
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
34
|
|
|
6
|
1
|
|
|
1
|
|
6
|
use strict; |
|
|
1
|
|
|
|
|
7
|
|
|
|
1
|
|
|
|
|
31
|
|
|
7
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
108
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
1090
|
use Perl6::Export::Attrs; |
|
|
1
|
|
|
|
|
9764
|
|
|
|
1
|
|
|
|
|
9
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub _input_pending_on { |
|
12
|
0
|
|
|
0
|
|
|
my ($fh) = @_; |
|
13
|
0
|
|
|
|
|
|
my $read_bits = ""; |
|
14
|
0
|
|
|
|
|
|
vec($read_bits, fileno($fh), 1) = 1; |
|
15
|
0
|
|
|
|
|
|
select $read_bits, undef, undef, 0.1; |
|
16
|
0
|
|
|
|
|
|
return $read_bits; |
|
17
|
|
|
|
|
|
|
} |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my @warning = ( |
|
20
|
|
|
|
|
|
|
"That input was ignored. Please don't press any keys yet.\n", |
|
21
|
|
|
|
|
|
|
"That input was ignored. Please wait a little longer.\n", |
|
22
|
|
|
|
|
|
|
"That input was also ignored. You might as well just wait, you know.\n", |
|
23
|
|
|
|
|
|
|
# "Look, there's no point typing yet. Your input isn't going anywhere.\n", |
|
24
|
|
|
|
|
|
|
#"Are you learning impaired? DON'T. TYPE. YET.\n", |
|
25
|
|
|
|
|
|
|
#"Okay, fine. Type whatever you like. Whatever makes you happy.\n", |
|
26
|
|
|
|
|
|
|
#"La la la la. I can't hear you.\n", |
|
27
|
|
|
|
|
|
|
"", |
|
28
|
|
|
|
|
|
|
); |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub busy (&) :Export(:MANDATORY) { |
|
31
|
0
|
|
|
0
|
1
|
|
my ($block_ref) = @_; |
|
32
|
0
|
|
|
|
|
|
my $count = 0; |
|
33
|
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
my ($read, $write); |
|
35
|
0
|
|
|
|
|
|
pipe $read, $write; |
|
36
|
0
|
|
|
|
|
|
my $child = fork; |
|
37
|
0
|
0
|
|
|
|
|
if (!$child) { |
|
38
|
0
|
|
|
|
|
|
close $read; |
|
39
|
0
|
|
|
|
|
|
$write->autoflush(1); |
|
40
|
0
|
|
|
|
|
|
while (1) { |
|
41
|
0
|
0
|
|
|
|
|
if (_input_pending_on(\*STDIN)) { |
|
42
|
0
|
|
|
|
|
|
my $res = ; |
|
43
|
0
|
|
|
|
|
|
print {$write} $res; |
|
|
0
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
print {*STDERR} "\n"; |
|
|
0
|
|
|
|
|
|
|
|
45
|
0
|
|
0
|
|
|
|
print {*STDERR} $warning[$count++] || $warning[-1]; |
|
|
0
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
print {*STDERR} "\n"; |
|
|
0
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
} |
|
49
|
0
|
|
|
|
|
|
exit; |
|
50
|
|
|
|
|
|
|
} |
|
51
|
0
|
|
|
|
|
|
close $write; |
|
52
|
0
|
|
|
|
|
|
local *ARGV; |
|
53
|
0
|
|
|
|
|
|
open *ARGV, '<', \""; |
|
54
|
0
|
|
|
|
|
|
$block_ref->(); |
|
55
|
0
|
|
|
|
|
|
kill 9, $child; |
|
56
|
0
|
|
|
|
|
|
wait; |
|
57
|
0
|
|
|
|
|
|
local $/; |
|
58
|
0
|
|
|
|
|
|
return $read; |
|
59
|
1
|
|
|
1
|
|
371
|
} |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
6
|
|
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; # Magic true value required at end of module |
|
63
|
|
|
|
|
|
|
__END__ |