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.51 by root, Fri Aug 14 14:07:44 2009 UTC vs.
Revision 1.52 by root, Fri Aug 14 15:13:20 2009 UTC

25 snd @msg_with_first_element_being_a_port; 25 snd @msg_with_first_element_being_a_port;
26 26
27 # creating/using ports, the simple way 27 # creating/using ports, the simple way
28 my $somple_port = port { my @msg = @_; 0 }; 28 my $somple_port = port { my @msg = @_; 0 };
29 29
30 # creating/using ports, type matching 30 # creating/using ports, tagged message matching
31 my $port = port; 31 my $port = port;
32 rcv $port, ping => sub { snd $_[0], "pong"; 0 }; 32 rcv $port, ping => sub { snd $_[0], "pong"; 0 };
33 rcv $port, pong => sub { warn "pong received\n"; 0 }; 33 rcv $port, pong => sub { warn "pong received\n"; 0 };
34 34
35 # create a port on another node 35 # create a port on another node
143 kil $SELF, die => $msg; 143 kil $SELF, die => $msg;
144} 144}
145 145
146=item $thisnode = NODE / $NODE 146=item $thisnode = NODE / $NODE
147 147
148The C<NODE> function returns, and the C<$NODE> variable contains 148The C<NODE> function returns, and the C<$NODE> variable contains the
149the noderef of the local node. The value is initialised by a call 149noderef of the local node. The value is initialised by a call to
150to C<become_public> or C<become_slave>, after which all local port 150C<initialise_node>.
151identifiers become invalid.
152 151
153=item $noderef = node_of $port 152=item $noderef = node_of $port
154 153
155Extracts and returns the noderef from a portid or a noderef. 154Extracts and returns the noderef from a port ID or a noderef.
156 155
157=item initialise_node $noderef, $seednode, $seednode... 156=item initialise_node $noderef, $seednode, $seednode...
158 157
159=item initialise_node "slave/", $master, $master... 158=item initialise_node "slave/", $master, $master...
160 159
279=item snd $port, type => @data 278=item snd $port, type => @data
280 279
281=item snd $port, @msg 280=item snd $port, @msg
282 281
283Send the given message to the given port ID, which can identify either 282Send the given message to the given port ID, which can identify either
284a local or a remote port, and can be either a string or soemthignt hat 283a local or a remote port, and must be a port ID.
285stringifies a sa port ID (such as a port object :).
286 284
287While the message can be about anything, it is highly recommended to use a 285While the message can be about anything, it is highly recommended to use a
288string as first element (a portid, or some word that indicates a request 286string as first element (a port ID, or some word that indicates a request
289type etc.). 287type etc.).
290 288
291The message data effectively becomes read-only after a call to this 289The message data effectively becomes read-only after a call to this
292function: modifying any argument is not allowed and can cause many 290function: modifying any argument is not allowed and can cause many
293problems. 291problems.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines