line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Plugin::IOMuxer::Layer; |
2
|
3
|
|
|
3
|
|
197817
|
use strict; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
85
|
|
3
|
3
|
|
|
3
|
|
17
|
use warnings; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
432
|
|
4
|
|
|
|
|
|
|
|
5
|
0
|
|
|
|
|
0
|
BEGIN { |
6
|
3
|
|
|
3
|
|
11
|
local $@ = undef; |
7
|
3
|
|
|
|
|
7
|
my $ok = eval { |
8
|
3
|
|
|
|
|
1560
|
require JSON::MaybeXS; |
9
|
3
|
|
|
|
|
15155
|
JSON::MaybeXS->import('JSON'); |
10
|
3
|
|
|
|
|
11
|
1; |
11
|
|
|
|
|
|
|
}; |
12
|
|
|
|
|
|
|
|
13
|
3
|
50
|
|
|
|
19
|
unless($ok) { |
14
|
0
|
|
|
|
|
0
|
require JSON::PP; |
15
|
0
|
|
|
|
|
0
|
*JSON = sub() { 'JSON::PP' }; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
3
|
|
|
|
|
11
|
my $json = JSON()->new->utf8(1); |
19
|
|
|
|
|
|
|
|
20
|
12
|
|
|
12
|
0
|
169
|
sub encode_json { $json->encode(@_) } |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
3
|
|
|
3
|
|
1506
|
use Time::HiRes qw/time/; |
|
3
|
|
|
|
|
3120
|
|
|
3
|
|
|
|
|
12
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
our $VERSION = '0.000007'; |
26
|
|
|
|
|
|
|
|
27
|
3
|
|
|
3
|
|
883
|
use Test2::Plugin::OpenFixPerlIO; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
61
|
|
28
|
3
|
|
|
3
|
|
1308
|
use IO::Handle; |
|
3
|
|
|
|
|
14259
|
|
|
3
|
|
|
|
|
666
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
our %MUXED; |
31
|
|
|
|
|
|
|
our %MUX_FILES; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub PUSHED { |
34
|
2
|
|
|
2
|
0
|
3375
|
my ($class, $mode, $handle) = @_; |
35
|
2
|
|
|
|
|
49
|
$handle->autoflush(1); |
36
|
2
|
|
|
|
|
135
|
bless {}, $class; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub WRITE { |
40
|
12
|
|
|
12
|
|
101
|
my ($self, $buffer, $handle) = @_; |
41
|
|
|
|
|
|
|
|
42
|
12
|
50
|
|
|
|
42
|
if ($self->{DIED}) { |
43
|
0
|
|
|
|
|
0
|
print $handle $buffer; |
44
|
0
|
|
|
|
|
0
|
return length($buffer); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
12
|
|
|
|
|
29
|
my $ok = eval { |
48
|
12
|
|
|
|
|
40
|
my $time = time; |
49
|
12
|
|
|
|
|
27
|
my $fileno = fileno($handle); |
50
|
|
|
|
|
|
|
|
51
|
12
|
|
|
|
|
59
|
my $json = encode_json({stamp => $time, fileno => $fileno, buffer => $buffer}); |
52
|
12
|
|
|
|
|
53
|
my $mh = $MUX_FILES{$MUXED{$fileno}}; |
53
|
12
|
|
|
|
|
139
|
print $mh $json, "\n"; |
54
|
|
|
|
|
|
|
|
55
|
12
|
|
|
|
|
39
|
1; |
56
|
|
|
|
|
|
|
}; |
57
|
12
|
|
|
|
|
26
|
my $err = $@; |
58
|
|
|
|
|
|
|
|
59
|
12
|
|
|
|
|
143
|
print $handle $buffer; |
60
|
|
|
|
|
|
|
|
61
|
12
|
50
|
|
|
|
45
|
unless ($ok) { |
62
|
0
|
|
|
|
|
0
|
$self->{DIED}++; |
63
|
0
|
|
|
|
|
0
|
die $err; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
12
|
|
|
|
|
62
|
return length($buffer); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
1; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
__END__ |