ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent-MP/MP/Kernel.pm
(Generate patch)

Comparing AnyEvent-MP/MP/Kernel.pm (file contents):
Revision 1.16 by root, Sat Aug 15 15:08:07 2009 UTC vs.
Revision 1.17 by root, Sun Aug 16 02:55:17 2009 UTC

39our @EXPORT = qw( 39our @EXPORT = qw(
40 %NODE %PORT %PORT_DATA $UNIQ $RUNIQ $ID 40 %NODE %PORT %PORT_DATA $UNIQ $RUNIQ $ID
41 connect_node add_node load_func snd_to_func 41 connect_node add_node load_func snd_to_func
42 42
43 NODE $NODE node_of snd kil 43 NODE $NODE node_of snd kil
44 port_is_local
44 resolve_node initialise_node 45 resolve_node initialise_node
45 known_nodes up_nodes mon_nodes node_is_known node_is_up 46 known_nodes up_nodes mon_nodes node_is_known node_is_up
46); 47);
47 48
48our $DEFAULT_PORT = "4040"; 49our $DEFAULT_PORT = "4040";
175 my ($noderef, undef) = split /#/, $_[0], 2; 176 my ($noderef, undef) = split /#/, $_[0], 2;
176 177
177 $noderef 178 $noderef
178} 179}
179 180
180sub TRACE() { 0 } 181BEGIN {
182 *TRACE = $ENV{PERL_ANYEVENT_MP_TRACE}
183 ? sub () { 1 }
184 : sub () { 0 };
185}
181 186
182sub _inject { 187sub _inject {
183 warn "RCV $SRCNODE->{noderef} -> @_\n" if TRACE;#d# 188 warn "RCV $SRCNODE->{noderef} -> @_\n" if TRACE;#d#
184 &{ $PORT{+shift} or return }; 189 &{ $PORT{+shift} or return };
185} 190}
231 236
232 warn "SND $noderef <- $portid @_\n" if TRACE;#d# 237 warn "SND $noderef <- $portid @_\n" if TRACE;#d#
233 238
234 ($NODE{$noderef} || add_node $noderef) 239 ($NODE{$noderef} || add_node $noderef)
235 ->{send} (["$portid", @_]); 240 ->{send} (["$portid", @_]);
241}
242
243=item $is_local = port_is_local $port
244
245Returns true iff the port is a local port.
246
247=cut
248
249sub port_is_local($) {
250 my ($noderef, undef) = split /#/, $_[0], 2;
251
252 $NODE{$noderef} == $NODE{""}
236} 253}
237 254
238=item snd_to_func $noderef, $func, @args 255=item snd_to_func $noderef, $func, @args
239 256
240Expects a noderef and a name of a function. Asynchronously tries to call 257Expects a noderef and a name of a function. Asynchronously tries to call
339 356
340 @others = map $_->recv, map +(resolve_node $_), @others; 357 @others = map $_->recv, map +(resolve_node $_), @others;
341 358
342 $NODE = $noderef->recv; 359 $NODE = $noderef->recv;
343 360
361 $NODE{$NODE} = $NODE{""};
362
344 for my $t (split /,/, $NODE) { 363 for my $t (split /,/, $NODE) {
345 $NODE{$t} = $NODE{""}; 364 $NODE{$t} = $NODE{""};
346 365
347 my ($host, $port) = AnyEvent::Socket::parse_hostport $t; 366 my ($host, $port) = AnyEvent::Socket::parse_hostport $t;
348 367

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines