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

Comparing AnyEvent-MP/MP.pm (file contents):
Revision 1.3 by root, Sat Aug 1 07:11:45 2009 UTC vs.
Revision 1.4 by root, Sat Aug 1 07:36:30 2009 UTC

172that Storable can serialise and deserialise is allowed, and for the local 172that Storable can serialise and deserialise is allowed, and for the local
173node, anything can be passed. 173node, anything can be passed.
174 174
175=cut 175=cut
176 176
177sub snd($@) { 177sub snd(@) {
178 my ($noderef, $port) = split /#/, shift, 2; 178 my ($noderef, $port) = split /#/, shift, 2;
179 179
180 add_node $noderef 180 add_node $noderef
181 unless exists $NODE{$noderef}; 181 unless exists $NODE{$noderef};
182 182
362 } 362 }
363 363
364 $PUBLIC = 1; 364 $PUBLIC = 1;
365} 365}
366 366
367=back
368
369=head1 NODE MESSAGES
370
371Nodes understand the following messages sent to them:
372
373=over 4
374
375=cut
376
367############################################################################# 377#############################################################################
368# self node code 378# self node code
369 379
370sub _new_port($) { 380sub _new_port($) {
371 my ($name) = @_; 381 my ($name) = @_;
379} 389}
380 390
381$NODE{""} = new AnyEvent::MP::Node::Self noderef => $NODE; 391$NODE{""} = new AnyEvent::MP::Node::Self noderef => $NODE;
382_new_port ""; 392_new_port "";
383 393
394=item relay => $port, @msg
395
396Simply forwards the message to the given port.
397
398=cut
399
384rcv "", relay => \&snd; 400rcv "", relay => \&snd;
401
402=item eval => $string[ @reply]
403
404Evaluates the given string. If C<@reply> is given, then a message of the
405form C<@reply, $@, @evalres> is sent (C<$reply[0]> is the port to reply to).
406
407=cut
408
409rcv "", eval => sub {
410 my (undef, $string, @reply) = @_;
411 my @res = eval $string;
412 snd @reply, "$@", @res if @reply;
413};
414
415=item time => @reply
416
417Replies the the current node time to C<@reply>.
418
419=cut
420
421rcv "", time => sub { shift; snd @_, AE::time };
385 422
386=back 423=back
387 424
388=head1 SEE ALSO 425=head1 SEE ALSO
389 426

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines