line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
22914
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
207
|
|
2
|
|
|
|
|
|
|
package Class::Delay; |
3
|
|
|
|
|
|
|
require Class::Delay::Message; |
4
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
sub import { |
7
|
1
|
|
|
1
|
|
20
|
my $package = caller; |
8
|
1
|
|
|
|
|
6
|
my $class = shift; |
9
|
1
|
|
|
|
|
3
|
my %args = @_; |
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
|
|
2
|
my @delayed; |
12
|
1
|
|
|
|
|
2
|
my @methods = @{ $args{methods} }; |
|
1
|
|
|
|
|
5
|
|
13
|
1
|
|
50
|
|
|
8
|
my $return = $args{return} || 1; |
14
|
1
|
|
|
|
|
3
|
for my $method (@methods) { |
15
|
1
|
|
|
1
|
|
7
|
no strict 'refs'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
188
|
|
16
|
3
|
|
|
|
|
17
|
*{"$package\::$method"} = sub { |
17
|
3
|
|
|
3
|
|
3044
|
push @delayed, Class::Delay::Message->new({ |
18
|
|
|
|
|
|
|
package => $package, |
19
|
|
|
|
|
|
|
method => $method, |
20
|
|
|
|
|
|
|
args => [ @_ ], |
21
|
|
|
|
|
|
|
is_trigger => 0, |
22
|
|
|
|
|
|
|
}); |
23
|
3
|
|
|
|
|
49
|
return $return; |
24
|
3
|
|
|
|
|
8
|
}; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
1
|
|
|
|
|
2
|
my $reorder = $args{reorder}; |
28
|
1
|
|
|
|
|
2
|
my @triggers = @{ $args{release} }; |
|
1
|
|
|
|
|
2
|
|
29
|
1
|
|
|
|
|
3
|
for my $method (@triggers) { |
30
|
|
|
|
|
|
|
my $sub = sub { |
31
|
1
|
|
|
1
|
|
1402
|
my $self = shift; |
32
|
|
|
|
|
|
|
# delete our placeholders |
33
|
1
|
|
|
|
|
3
|
for my $method (@methods, @triggers) { |
34
|
1
|
|
|
1
|
|
13
|
no strict 'refs'; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
7400
|
|
35
|
4
|
|
|
|
|
10
|
local *newglob; |
36
|
4
|
|
|
|
|
5
|
*{"$package\::$method"} = *newglob; |
|
4
|
|
|
|
|
16
|
|
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
1
|
|
|
|
|
10
|
push @delayed, Class::Delay::Message->new({ |
40
|
|
|
|
|
|
|
package => $package, |
41
|
|
|
|
|
|
|
method => $method, |
42
|
|
|
|
|
|
|
args => [ $self, @_ ], |
43
|
|
|
|
|
|
|
is_trigger => 1, |
44
|
|
|
|
|
|
|
}); |
45
|
|
|
|
|
|
|
|
46
|
1
|
50
|
|
|
|
14
|
@delayed = $reorder->( @delayed ) if $reorder; |
47
|
|
|
|
|
|
|
# redispatch them in their new order |
48
|
1
|
|
|
|
|
10
|
$_->resume for @delayed; |
49
|
1
|
|
|
|
|
8
|
return $return; |
50
|
1
|
|
|
|
|
4
|
}; |
51
|
|
|
|
|
|
|
|
52
|
1
|
|
|
1
|
|
10
|
no strict 'refs'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
111
|
|
53
|
1
|
|
|
|
|
2
|
*{"$package\::$method"} = $sub; |
|
1
|
|
|
|
|
2185
|
|
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |
58
|
|
|
|
|
|
|
__END__ |