line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# You may distribute under the terms of either the GNU General Public License |
2
|
|
|
|
|
|
|
# or the Artistic License (the same terms as Perl itself) |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# (C) Paul Evans, 2015 -- leonerd@leonerd.org.uk |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package Event::Distributor::Action; |
7
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
60679
|
use strict; |
|
3
|
|
|
|
|
13
|
|
|
3
|
|
|
|
|
66
|
|
9
|
3
|
|
|
3
|
|
11
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
72
|
|
10
|
3
|
|
|
3
|
|
13
|
use base qw( Event::Distributor::_Event ); |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
498
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
13
|
|
|
|
|
|
|
|
14
|
3
|
|
|
3
|
|
15
|
use Carp; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
145
|
|
15
|
|
|
|
|
|
|
|
16
|
3
|
|
|
3
|
|
14
|
use Future; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
350
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 NAME |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
C - an event that requires one subscriber |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 DESCRIPTION |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
This subclass of L requires exactly one subscriber |
25
|
|
|
|
|
|
|
at the time that it is invoked. It passes on the caller's arguments to the |
26
|
|
|
|
|
|
|
subscriber, and the subscriber's return value back to the caller. |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=cut |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub subscribe |
31
|
|
|
|
|
|
|
{ |
32
|
3
|
|
|
3
|
1
|
82
|
my $self = shift; |
33
|
3
|
100
|
|
|
|
6
|
$self->subscribers and croak "Too many subscribers"; |
34
|
|
|
|
|
|
|
|
35
|
2
|
|
|
|
|
19
|
$self->SUPER::subscribe( @_ ); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub fire |
39
|
|
|
|
|
|
|
{ |
40
|
2
|
|
|
2
|
1
|
7
|
my $self = shift; |
41
|
2
|
|
|
|
|
3
|
my ( $dist, @args ) = @_; |
42
|
|
|
|
|
|
|
|
43
|
2
|
100
|
|
|
|
5
|
my @subs = $self->subscribers or |
44
|
|
|
|
|
|
|
return Future->fail( "No subscribers" ); |
45
|
|
|
|
|
|
|
|
46
|
1
|
|
|
|
|
6
|
Future->call( $subs[0], $dist, @args ); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 AUTHOR |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Paul Evans |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=cut |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
0x55AA; |