line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package POE::Session::AttributeBased; |
2
|
2
|
|
|
2
|
|
372161
|
use 5.008000; |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
85
|
|
3
|
2
|
|
|
2
|
|
2433
|
use Attribute::Handlers; |
|
2
|
|
|
|
|
16157
|
|
|
2
|
|
|
|
|
16
|
|
4
|
|
|
|
|
|
|
require POE::Session; # for the offset constants |
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
94
|
use warnings; |
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
107
|
|
7
|
2
|
|
|
2
|
|
10
|
use strict; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
402
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
POE::Session::AttributeBased - POE::Session syntax sweetener |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 VERSION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Version 0.10 |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our $VERSION = '0.10'; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 SYNOPSIS |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
#!perl |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
package Foo; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
use Test::More tests => 7; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
use POE; |
30
|
|
|
|
|
|
|
use base 'POE::Session::AttributeBased'; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub _start : State { |
33
|
|
|
|
|
|
|
my $k : KERNEL; |
34
|
|
|
|
|
|
|
my $h : HEAP; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
ok( 1, "in _start" ); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
$k->yield( tick => 5 ); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub tick : State { |
42
|
|
|
|
|
|
|
my $k : KERNEL; |
43
|
|
|
|
|
|
|
my $count : ARG0; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
ok( 1, "in tick" ); |
46
|
|
|
|
|
|
|
return 0 unless $count; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
$k->yield( tick => $count - 1 ); |
49
|
|
|
|
|
|
|
return 1; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
POE::Session->create( |
53
|
|
|
|
|
|
|
Foo->inline_states(), |
54
|
|
|
|
|
|
|
); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
POE::Kernel->run(); |
57
|
|
|
|
|
|
|
exit; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 ABSTRACT |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
A simple attribute handler mixin that makes POE state easier to keep track of. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 DESCRIPTION |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Provides an attribute handler that does some bookkeeping for state |
66
|
|
|
|
|
|
|
handlers. There have been a few of these classes for POE. This |
67
|
|
|
|
|
|
|
is probably the most minimal. It supports only the inline attribute syntax. |
68
|
|
|
|
|
|
|
but that seems sufficient for cranking up a POE session. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 FUNCTIONS |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head2 State |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
The state hander attribute. Never called directly. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=cut |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
my %State; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub State : ATTR(CODE) { |
81
|
2
|
|
|
2
|
1
|
2143
|
my ( $package, $symbol, $code, $attribute, $data ) = @_; |
82
|
|
|
|
|
|
|
|
83
|
2
|
|
|
|
|
6
|
$State{$package}{ *{$symbol}{NAME} } = $code; |
|
2
|
|
|
|
|
8
|
|
84
|
2
|
|
|
2
|
|
12
|
} |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
9
|
|
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head2 Offset |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
POE::Session argument offset handler. |
89
|
|
|
|
|
|
|
This use of the DB module to get extra info from caller might be risky. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=cut |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub Offset { |
94
|
14
|
|
|
14
|
1
|
28
|
my $ref = $_[2]; |
95
|
14
|
|
|
|
|
20
|
my $attribute = $_[3]; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
package DB; |
98
|
14
|
|
|
|
|
103
|
my @x = caller(5); |
99
|
14
|
|
|
|
|
92
|
$$ref = $DB::args[ POE::Session->$attribute() ]; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head2 OBJECT |
103
|
|
|
|
|
|
|
=cut |
104
|
2
|
|
|
2
|
1
|
663
|
sub OBJECT : ATTR(SCALAR) { Offset @_; } |
|
2
|
|
|
0
|
|
4
|
|
|
2
|
|
|
|
|
8
|
|
|
0
|
|
|
|
|
0
|
|
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 SESSION |
107
|
|
|
|
|
|
|
=cut |
108
|
|
|
|
|
|
|
|
109
|
2
|
|
|
2
|
1
|
658
|
sub SESSION : ATTR(SCALAR) { Offset @_; } |
|
2
|
|
|
0
|
|
4
|
|
|
2
|
|
|
|
|
8
|
|
|
0
|
|
|
|
|
0
|
|
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head2 KERNEL |
112
|
|
|
|
|
|
|
=cut |
113
|
2
|
|
|
2
|
1
|
791
|
sub KERNEL : ATTR(SCALAR) { Offset @_; } |
|
2
|
|
|
7
|
|
4
|
|
|
2
|
|
|
|
|
8
|
|
|
7
|
|
|
|
|
8338
|
|
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head2 HEAP |
116
|
|
|
|
|
|
|
=cut |
117
|
2
|
|
|
2
|
1
|
805
|
sub HEAP : ATTR(SCALAR) { Offset @_; } |
|
2
|
|
|
1
|
|
4
|
|
|
2
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
592
|
|
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head2 STATE |
120
|
|
|
|
|
|
|
=cut |
121
|
2
|
|
|
2
|
1
|
1436
|
sub STATE : ATTR(SCALAR) { Offset @_; } |
|
2
|
|
|
0
|
|
5
|
|
|
2
|
|
|
|
|
8
|
|
|
0
|
|
|
|
|
0
|
|
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head2 SENDER |
124
|
|
|
|
|
|
|
=cut |
125
|
2
|
|
|
2
|
1
|
568
|
sub SENDER : ATTR(SCALAR) { Offset @_; } |
|
2
|
|
|
0
|
|
4
|
|
|
2
|
|
|
|
|
10
|
|
|
0
|
|
|
|
|
0
|
|
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head2 CALLER_FILE |
128
|
|
|
|
|
|
|
=cut |
129
|
2
|
|
|
2
|
1
|
682
|
sub CALLER_FILE : ATTR(SCALAR) { Offset @_; } |
|
2
|
|
|
0
|
|
3
|
|
|
2
|
|
|
|
|
8
|
|
|
0
|
|
|
|
|
0
|
|
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head2 CALLER_LINE |
132
|
|
|
|
|
|
|
=cut |
133
|
|
|
|
|
|
|
|
134
|
2
|
|
|
2
|
1
|
844
|
sub CALLER_LINE : ATTR(SCALAR) { Offset @_; } |
|
2
|
|
|
0
|
|
4
|
|
|
2
|
|
|
|
|
9
|
|
|
0
|
|
|
|
|
0
|
|
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head2 CALLER_STATE |
137
|
|
|
|
|
|
|
=cut |
138
|
|
|
|
|
|
|
|
139
|
2
|
|
|
2
|
1
|
626
|
sub CALLER_STATE : ATTR(SCALAR) { Offset @_; } |
|
2
|
|
|
0
|
|
3
|
|
|
2
|
|
|
|
|
14
|
|
|
0
|
|
|
|
|
0
|
|
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head2 ARG0 |
142
|
|
|
|
|
|
|
=cut |
143
|
|
|
|
|
|
|
|
144
|
2
|
|
|
2
|
1
|
905
|
sub ARG0 : ATTR(SCALAR) { Offset @_; } |
|
2
|
|
|
6
|
|
3
|
|
|
2
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
3410
|
|
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head2 ARG1 |
147
|
|
|
|
|
|
|
=cut |
148
|
|
|
|
|
|
|
|
149
|
2
|
|
|
2
|
1
|
992
|
sub ARG1 : ATTR(SCALAR) { Offset @_; } |
|
2
|
|
|
0
|
|
105
|
|
|
2
|
|
|
|
|
8
|
|
|
0
|
|
|
|
|
0
|
|
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head2 ARG2 |
152
|
|
|
|
|
|
|
=cut |
153
|
|
|
|
|
|
|
|
154
|
2
|
|
|
2
|
1
|
762
|
sub ARG2 : ATTR(SCALAR) { Offset @_; } |
|
2
|
|
|
0
|
|
5
|
|
|
2
|
|
|
|
|
9
|
|
|
0
|
|
|
|
|
0
|
|
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head2 ARG3 |
157
|
|
|
|
|
|
|
=cut |
158
|
|
|
|
|
|
|
|
159
|
2
|
|
|
2
|
1
|
988
|
sub ARG3 : ATTR(SCALAR) { Offset @_; } |
|
2
|
|
|
0
|
|
2
|
|
|
2
|
|
|
|
|
16
|
|
|
0
|
|
|
|
|
0
|
|
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head2 ARG4 |
162
|
|
|
|
|
|
|
=cut |
163
|
|
|
|
|
|
|
|
164
|
2
|
|
|
2
|
1
|
750
|
sub ARG4 : ATTR(SCALAR) { Offset @_; } |
|
2
|
|
|
0
|
|
4
|
|
|
2
|
|
|
|
|
8
|
|
|
0
|
|
|
|
|
0
|
|
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head2 ARG5 |
167
|
|
|
|
|
|
|
=cut |
168
|
|
|
|
|
|
|
|
169
|
2
|
|
|
2
|
1
|
809
|
sub ARG5 : ATTR(SCALAR) { Offset @_; } |
|
2
|
|
|
0
|
|
4
|
|
|
2
|
|
|
|
|
9
|
|
|
0
|
|
|
|
|
0
|
|
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head2 ARG6 |
172
|
|
|
|
|
|
|
=cut |
173
|
|
|
|
|
|
|
|
174
|
2
|
|
|
2
|
1
|
762
|
sub ARG6 : ATTR(SCALAR) { Offset @_; } |
|
2
|
|
|
0
|
|
4
|
|
|
2
|
|
|
|
|
8
|
|
|
0
|
|
|
|
|
0
|
|
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head2 ARG7 |
177
|
|
|
|
|
|
|
=cut |
178
|
|
|
|
|
|
|
|
179
|
2
|
|
|
2
|
1
|
880
|
sub ARG7 : ATTR(SCALAR) { Offset @_; } |
|
2
|
|
|
0
|
|
3
|
|
|
2
|
|
|
|
|
10
|
|
|
0
|
|
|
|
|
0
|
|
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=head2 ARG8 |
182
|
|
|
|
|
|
|
=cut |
183
|
|
|
|
|
|
|
|
184
|
2
|
|
|
2
|
1
|
1354
|
sub ARG8 : ATTR(SCALAR) { Offset @_; } |
|
2
|
|
|
0
|
|
5
|
|
|
2
|
|
|
|
|
11
|
|
|
0
|
|
|
|
|
0
|
|
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=head2 ARG9 |
187
|
|
|
|
|
|
|
=cut |
188
|
|
|
|
|
|
|
|
189
|
2
|
|
|
2
|
1
|
16331
|
sub ARG9 : ATTR(SCALAR) { Offset @_; } |
|
2
|
|
|
0
|
|
6
|
|
|
2
|
|
|
|
|
13
|
|
|
0
|
|
|
|
|
0
|
|
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=head2 inline_states |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
Returns the list of states in a format that is usable by POE::Session->create. |
194
|
|
|
|
|
|
|
Can also specify what to return as the hash key so that it is useful in |
195
|
|
|
|
|
|
|
packages like POE::Component::Server::TCP where the state list has a |
196
|
|
|
|
|
|
|
different tag. |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=cut |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
sub inline_states { |
201
|
1
|
|
50
|
1
|
1
|
51
|
my $tag = $_[1] || 'inline_states'; |
202
|
|
|
|
|
|
|
|
203
|
1
|
|
|
|
|
14
|
return ( $tag => $State{ ( caller() )[0] } ); |
204
|
|
|
|
|
|
|
} |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=head1 AUTHOR |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
Chris Fedde, C<< >> |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=head1 BUGS |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
213
|
|
|
|
|
|
|
C, or through the web interface at |
214
|
|
|
|
|
|
|
L. |
215
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
216
|
|
|
|
|
|
|
your bug as I make changes. |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=head1 SUPPORT |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
perldoc POE::Session::AttributeBased |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
You can also look for information at: |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=over 4 |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
L |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=item * CPAN Ratings |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
L |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
L |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
=item * Search CPAN |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
L |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
=back |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
Copyright 2010 Chris Fedde, all rights reserved. |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
253
|
|
|
|
|
|
|
under the same terms as Perl itself. |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
=cut |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
1; # End of POE::Session::AttributeBased |