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.4 by root, Sat Aug 1 07:36:30 2009 UTC vs.
Revision 1.5 by root, Sat Aug 1 07:44:02 2009 UTC

52 52
53Initially, nodes are either private (single-process only) or hidden 53Initially, nodes are either private (single-process only) or hidden
54(connected to a master node only). Only when they epxlicitly "become 54(connected to a master node only). Only when they epxlicitly "become
55public" can you send them messages from unrelated other nodes. 55public" can you send them messages from unrelated other nodes.
56 56
57=item noderef - C<host:port,host:port...>, C<id@noderef, C<id> 57=item noderef - C<host:port,host:port...>, C<id@noderef>, C<id>
58 58
59A noderef is a string that either uniquely identifies a given node (for 59A noderef is a string that either uniquely identifies a given node (for
60private and hidden nodes), or contains a recipe on how to reach a given 60private and hidden nodes), or contains a recipe on how to reach a given
61node (for public nodes). 61node (for public nodes).
62 62
366 366
367=back 367=back
368 368
369=head1 NODE MESSAGES 369=head1 NODE MESSAGES
370 370
371Nodes understand the following messages sent to them: 371Nodes understand the following messages sent to them. Many of them take
372arguments called C<@reply>, which will simply be used to compose a reply
373message - C<$reply[0]> is the port to reply to, C<$reply[1]> the type and
374the remaining arguments are simply the message data.
372 375
373=over 4 376=over 4
374 377
375=cut 378=cut
376 379
400rcv "", relay => \&snd; 403rcv "", relay => \&snd;
401 404
402=item eval => $string[ @reply] 405=item eval => $string[ @reply]
403 406
404Evaluates the given string. If C<@reply> is given, then a message of the 407Evaluates 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). 408form C<@reply, $@, @evalres> is sent.
409
410Example: crash another node.
411
412 snd $othernode, eval => "exit";
406 413
407=cut 414=cut
408 415
409rcv "", eval => sub { 416rcv "", eval => sub {
410 my (undef, $string, @reply) = @_; 417 my (undef, $string, @reply) = @_;
414 421
415=item time => @reply 422=item time => @reply
416 423
417Replies the the current node time to C<@reply>. 424Replies the the current node time to C<@reply>.
418 425
426Example: tell the current node to send the current time to C<$myport> in a
427C<timereply> message.
428
429 snd $NODE, time => $myport, timereply => 1, 2;
430 # => snd $myport, timereply => 1, 2, <time>
431
419=cut 432=cut
420 433
421rcv "", time => sub { shift; snd @_, AE::time }; 434rcv "", time => sub { shift; snd @_, AE::time };
422 435
423=back 436=back

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines