line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Worlogog::Incident; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
64438
|
use warnings; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
131
|
|
4
|
4
|
|
|
4
|
|
17
|
use strict; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
181
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
7
|
|
|
|
|
|
|
|
8
|
4
|
|
|
4
|
|
17
|
use Carp qw(carp); |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
277
|
|
9
|
4
|
|
|
4
|
|
1917
|
use Scope::OnExit::Wrap qw(on_scope_exit); |
|
4
|
|
|
|
|
2217
|
|
|
4
|
|
|
|
|
228
|
|
10
|
4
|
|
|
4
|
|
1822
|
use Return::MultiLevel qw(with_return); |
|
4
|
|
|
|
|
12907
|
|
|
4
|
|
|
|
|
219
|
|
11
|
4
|
|
|
4
|
|
1924
|
use Worlogog::Restart; |
|
4
|
|
|
|
|
15981
|
|
|
4
|
|
|
|
|
33
|
|
12
|
4
|
|
|
4
|
|
2258
|
use Dispatch::Class qw(dispatch class_case); |
|
4
|
|
|
|
|
42267
|
|
|
4
|
|
|
|
|
21
|
|
13
|
|
|
|
|
|
|
|
14
|
4
|
|
|
4
|
|
902
|
use parent 'Exporter::Tiny'; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
27
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our @EXPORT_OK = qw( |
17
|
|
|
|
|
|
|
handler_bind |
18
|
|
|
|
|
|
|
handler_case |
19
|
|
|
|
|
|
|
report |
20
|
|
|
|
|
|
|
error |
21
|
|
|
|
|
|
|
cerror |
22
|
|
|
|
|
|
|
warn |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
#our @CARP_NOT = qw(Worlogog::Restart); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
our @handlers; |
28
|
|
|
|
|
|
|
our $barrier; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# hakurei |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub handler_bind (&$) { |
34
|
6
|
|
|
6
|
1
|
4027
|
my ($body, $handler) = @_; |
35
|
6
|
|
|
|
|
10
|
my $limit = @handlers; |
36
|
6
|
|
|
6
|
|
153
|
my $guard = on_scope_exit { splice @handlers, $limit }; |
|
6
|
|
|
|
|
540
|
|
37
|
6
|
100
|
|
|
|
39
|
if (ref($handler) eq 'ARRAY') { |
38
|
2
|
|
|
|
|
19
|
$handler = dispatch @$handler; |
39
|
|
|
|
|
|
|
} |
40
|
6
|
|
|
|
|
29
|
push @handlers, \&$handler; |
41
|
6
|
|
|
|
|
27
|
$body->() |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub handler_case (&$) { |
45
|
3
|
|
|
3
|
1
|
95
|
my ($body, $genhandler) = @_; |
46
|
3
|
|
|
|
|
7
|
my $limit = @handlers; |
47
|
3
|
|
|
3
|
|
86
|
my $guard = on_scope_exit { splice @handlers, $limit }; |
|
3
|
|
|
|
|
135
|
|
48
|
3
|
100
|
|
|
|
28
|
if (ref($genhandler) eq 'ARRAY') { |
49
|
1
|
|
|
|
|
5
|
$genhandler = class_case @$genhandler; |
50
|
|
|
|
|
|
|
} |
51
|
3
|
|
|
|
|
16
|
$genhandler = \&$genhandler; |
52
|
3
|
|
|
|
|
4
|
my $wantlist = wantarray; |
53
|
|
|
|
|
|
|
my @v = with_return { |
54
|
3
|
|
|
3
|
|
361
|
my ($return) = @_; |
55
|
|
|
|
|
|
|
push @handlers, sub { |
56
|
3
|
50
|
|
|
|
8
|
my $handler = $genhandler->(@_) or return; |
57
|
3
|
|
|
|
|
40
|
$return->($handler, @_); |
58
|
3
|
|
|
|
|
15
|
}; |
59
|
3
|
100
|
|
|
|
13
|
unless (defined $wantlist) { |
60
|
2
|
|
|
|
|
6
|
$body->(); |
61
|
0
|
|
|
|
|
0
|
return; |
62
|
|
|
|
|
|
|
} |
63
|
1
|
50
|
|
|
|
4
|
undef, $wantlist ? $body->() : scalar $body->() |
64
|
3
|
|
|
|
|
22
|
}; |
65
|
3
|
50
|
|
|
|
75
|
if (my $f = shift @v) { |
66
|
3
|
|
|
|
|
10
|
return $f->(@v); |
67
|
|
|
|
|
|
|
} |
68
|
0
|
0
|
|
|
|
0
|
$wantlist ? @v : $v[0] |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# reimu |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub report { |
75
|
11
|
|
|
11
|
1
|
16
|
my ($incident) = @_; |
76
|
11
|
50
|
|
|
|
25
|
my $limit = defined $barrier ? $barrier : $#handlers; |
77
|
11
|
|
|
|
|
28
|
for my $i (reverse 0 .. $limit) { |
78
|
9
|
|
|
|
|
13
|
my $h = $handlers[$i]; |
79
|
9
|
|
|
|
|
10
|
local $barrier = $i - 1; |
80
|
9
|
|
|
|
|
20
|
$h->($incident); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub error { |
85
|
11
|
|
|
11
|
1
|
1004
|
my ($incident) = @_; |
86
|
11
|
|
|
|
|
25
|
report $incident; |
87
|
2
|
|
|
|
|
35
|
die $incident; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub cerror { |
91
|
2
|
|
|
2
|
1
|
7
|
my ($incident) = @_; |
92
|
|
|
|
|
|
|
Worlogog::Restart::case { |
93
|
2
|
|
|
2
|
|
111
|
error $incident; |
94
|
|
|
|
|
|
|
} { |
95
|
1
|
|
|
1
|
|
53
|
continue => sub {}, |
96
|
2
|
|
|
|
|
14
|
}; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub warn { |
100
|
0
|
|
|
0
|
1
|
|
my ($incident) = @_; |
101
|
|
|
|
|
|
|
Worlogog::Restart::case { |
102
|
0
|
|
|
0
|
|
|
report $incident; |
103
|
0
|
|
|
|
|
|
carp $incident; |
104
|
|
|
|
|
|
|
} { |
105
|
0
|
|
|
0
|
|
|
muffle_warning => sub {}, |
106
|
0
|
|
|
|
|
|
}; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
'ok' |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
__END__ |