--- AnyEvent-MP/MP.pm 2009/08/01 07:36:30 1.4 +++ AnyEvent-MP/MP.pm 2009/08/01 15:04:30 1.7 @@ -29,6 +29,10 @@ Despite its simplicity, you can securely message other processes running on the same or other hosts. +At the moment, this module family is severly brokena nd underdocumented, +so do not use. This was uploaded mainly to resreve the CPAN namespace - +stay tuned! + =head1 CONCEPTS =over 4 @@ -54,7 +58,7 @@ (connected to a master node only). Only when they epxlicitly "become public" can you send them messages from unrelated other nodes. -=item noderef - C, C +=item noderef - C, C, C A noderef is a string that either uniquely identifies a given node (for private and hidden nodes), or contains a recipe on how to reach a given @@ -83,7 +87,7 @@ use base "Exporter"; -our $VERSION = '0.0'; +our $VERSION = '0.01'; our @EXPORT = qw(NODE $NODE $PORT snd rcv _any_); our $DEFAULT_SECRET; @@ -113,6 +117,7 @@ =cut our $UNIQ = sprintf "%x.%x", $$, time; # per-process/node unique cookie +our $ID = "a0"; our $PUBLIC = 0; our $NODE; our $PORT; @@ -256,7 +261,7 @@ } for (@{ $port->{any} }) { - $_ && [@_[0..$#{$_->[1]}]] ~~ $_->[1] + $_ && [@_[0..$#{$_->[1]}]] ~~ $_->[1] && &{$_->[0]} && undef $_; } @@ -368,7 +373,10 @@ =head1 NODE MESSAGES -Nodes understand the following messages sent to them: +Nodes understand the following messages sent to them. Many of them take +arguments called C<@reply>, which will simply be used to compose a reply +message - C<$reply[0]> is the port to reply to, C<$reply[1]> the type and +the remaining arguments are simply the message data. =over 4 @@ -391,18 +399,30 @@ $NODE{""} = new AnyEvent::MP::Node::Self noderef => $NODE; _new_port ""; +=item devnull => ... + +Generic data sink/CPU heat conversion. + +=cut + +rcv "", devnull => sub { () }; + =item relay => $port, @msg Simply forwards the message to the given port. =cut -rcv "", relay => \&snd; +rcv "", relay => sub { \&snd; () }; =item eval => $string[ @reply] Evaluates the given string. If C<@reply> is given, then a message of the -form C<@reply, $@, @evalres> is sent (C<$reply[0]> is the port to reply to). +form C<@reply, $@, @evalres> is sent. + +Example: crash another node. + + snd $othernode, eval => "exit"; =cut @@ -410,15 +430,22 @@ my (undef, $string, @reply) = @_; my @res = eval $string; snd @reply, "$@", @res if @reply; + () }; =item time => @reply Replies the the current node time to C<@reply>. +Example: tell the current node to send the current time to C<$myport> in a +C message. + + snd $NODE, time => $myport, timereply => 1, 2; + # => snd $myport, timereply => 1, 2,