line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Worlogog::Incident; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
105930
|
use warnings; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
129
|
|
4
|
4
|
|
|
4
|
|
25
|
use strict; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
266
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
7
|
|
|
|
|
|
|
|
8
|
4
|
|
|
|
|
71
|
use Sub::Exporter -setup => { |
9
|
|
|
|
|
|
|
exports => [ |
10
|
|
|
|
|
|
|
qw( |
11
|
|
|
|
|
|
|
handler_bind |
12
|
|
|
|
|
|
|
handler_case |
13
|
|
|
|
|
|
|
report |
14
|
|
|
|
|
|
|
error |
15
|
|
|
|
|
|
|
cerror |
16
|
|
|
|
|
|
|
warn |
17
|
|
|
|
|
|
|
) |
18
|
|
|
|
|
|
|
], |
19
|
4
|
|
|
4
|
|
4328
|
}; |
|
4
|
|
|
|
|
77800
|
|
20
|
|
|
|
|
|
|
|
21
|
4
|
|
|
4
|
|
1720
|
use Carp qw(carp croak); |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
241
|
|
22
|
4
|
|
|
4
|
|
3839
|
use Scope::OnExit::Wrap qw(on_scope_exit); |
|
4
|
|
|
|
|
3353
|
|
|
4
|
|
|
|
|
253
|
|
23
|
4
|
|
|
4
|
|
3495
|
use Return::MultiLevel qw(with_return); |
|
4
|
|
|
|
|
19545
|
|
|
4
|
|
|
|
|
279
|
|
24
|
4
|
|
|
4
|
|
3527
|
use Worlogog::Restart; |
|
4
|
|
|
|
|
5439
|
|
|
4
|
|
|
|
|
213
|
|
25
|
4
|
|
|
4
|
|
4041
|
use Dispatch::Class qw(dispatch class_case); |
|
4
|
|
|
|
|
2921
|
|
|
4
|
|
|
|
|
32
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
#our @CARP_NOT = qw(Worlogog::Restart); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
our @handlers; |
30
|
|
|
|
|
|
|
our $barrier; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# hakurei |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub handler_bind (&$) { |
36
|
6
|
|
|
6
|
1
|
6090
|
my ($body, $handler) = @_; |
37
|
6
|
|
|
|
|
12
|
my $limit = @handlers; |
38
|
6
|
|
|
6
|
|
172
|
my $guard = on_scope_exit { splice @handlers, $limit }; |
|
6
|
|
|
|
|
616
|
|
39
|
6
|
100
|
|
|
|
69
|
if (ref($handler) eq 'ARRAY') { |
40
|
2
|
|
|
|
|
15
|
$handler = dispatch @$handler; |
41
|
|
|
|
|
|
|
} |
42
|
6
|
|
|
|
|
58
|
push @handlers, \&$handler; |
43
|
6
|
|
|
|
|
18
|
$body->() |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub handler_case (&$) { |
47
|
3
|
|
|
3
|
1
|
102
|
my ($body, $genhandler) = @_; |
48
|
3
|
|
|
|
|
10
|
my $limit = @handlers; |
49
|
3
|
|
|
3
|
|
114
|
my $guard = on_scope_exit { splice @handlers, $limit }; |
|
3
|
|
|
|
|
195
|
|
50
|
3
|
100
|
|
|
|
34
|
if (ref($genhandler) eq 'ARRAY') { |
51
|
1
|
|
|
|
|
5
|
$genhandler = class_case @$genhandler; |
52
|
|
|
|
|
|
|
} |
53
|
3
|
|
|
|
|
24
|
$genhandler = \&$genhandler; |
54
|
3
|
|
|
|
|
7
|
my $wantlist = wantarray; |
55
|
|
|
|
|
|
|
my @v = with_return { |
56
|
3
|
|
|
3
|
|
453
|
my ($return) = @_; |
57
|
|
|
|
|
|
|
push @handlers, sub { |
58
|
3
|
50
|
|
|
|
12
|
my $handler = $genhandler->(@_) or return; |
59
|
3
|
|
|
|
|
57
|
$return->($handler, @_); |
60
|
3
|
|
|
|
|
17
|
}; |
61
|
3
|
100
|
|
|
|
12
|
unless (defined $wantlist) { |
62
|
2
|
|
|
|
|
6
|
$body->(); |
63
|
0
|
|
|
|
|
0
|
return; |
64
|
|
|
|
|
|
|
} |
65
|
1
|
50
|
|
|
|
6
|
undef, $wantlist ? $body->() : scalar $body->() |
66
|
3
|
|
|
|
|
28
|
}; |
67
|
3
|
50
|
|
|
|
86
|
if (my $f = shift @v) { |
68
|
3
|
|
|
|
|
11
|
return $f->(@v); |
69
|
|
|
|
|
|
|
} |
70
|
0
|
0
|
|
|
|
0
|
$wantlist ? @v : $v[0] |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# reimu |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub report { |
77
|
11
|
|
|
11
|
1
|
15
|
my ($incident) = @_; |
78
|
11
|
50
|
|
|
|
34
|
my $limit = defined $barrier ? $barrier : $#handlers; |
79
|
11
|
|
|
|
|
31
|
for my $i (reverse 0 .. $limit) { |
80
|
9
|
|
|
|
|
15
|
my $h = $handlers[$i]; |
81
|
9
|
|
|
|
|
14
|
local $barrier = $i - 1; |
82
|
9
|
|
|
|
|
21
|
$h->($incident); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub error { |
87
|
11
|
|
|
11
|
1
|
1464
|
my ($incident) = @_; |
88
|
11
|
|
|
|
|
26
|
report $incident; |
89
|
2
|
|
|
|
|
113
|
die $incident; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub cerror { |
93
|
2
|
|
|
2
|
1
|
11
|
my ($incident) = @_; |
94
|
|
|
|
|
|
|
Worlogog::Restart::case { |
95
|
2
|
|
|
2
|
|
153
|
error $incident; |
96
|
|
|
|
|
|
|
} { |
97
|
1
|
|
|
1
|
|
79
|
continue => sub {}, |
98
|
2
|
|
|
|
|
19
|
}; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub warn { |
102
|
0
|
|
|
0
|
1
|
|
my ($incident) = @_; |
103
|
|
|
|
|
|
|
Worlogog::Restart::case { |
104
|
0
|
|
|
0
|
|
|
report $incident; |
105
|
0
|
|
|
|
|
|
carp $incident; |
106
|
|
|
|
|
|
|
} { |
107
|
0
|
|
|
0
|
|
|
muffle_warning => sub {}, |
108
|
0
|
|
|
|
|
|
}; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
'ok' |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
__END__ |