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

Comparing cvsroot/AnyEvent-MP/MP.pm (file contents):
Revision 1.121 by root, Tue Feb 28 18:37:24 2012 UTC vs.
Revision 1.123 by root, Thu Mar 1 19:37:59 2012 UTC

82 82
83Ports are represented by (printable) strings called "port IDs". 83Ports are represented by (printable) strings called "port IDs".
84 84
85=item port ID - C<nodeid#portname> 85=item port ID - C<nodeid#portname>
86 86
87A port ID is the concatenation of a node ID, a hash-mark (C<#>) as 87A port ID is the concatenation of a node ID, a hash-mark (C<#>)
88separator, and a port name (a printable string of unspecified format). 88as separator, and a port name (a printable string of unspecified
89format created by AnyEvent::MP).
89 90
90=item node 91=item node
91 92
92A node is a single process containing at least one port - the node port, 93A node is a single process containing at least one port - the node port,
93which enables nodes to manage each other remotely, and to create new 94which enables nodes to manage each other remotely, and to create new
267That means that the values specified in the profile have highest priority 268That means that the values specified in the profile have highest priority
268and the values specified directly via C<configure> have lowest priority, 269and the values specified directly via C<configure> have lowest priority,
269and can only be used to specify defaults. 270and can only be used to specify defaults.
270 271
271If the profile specifies a node ID, then this will become the node ID of 272If the profile specifies a node ID, then this will become the node ID of
272this process. If not, then the profile name will be used as node ID. The 273this process. If not, then the profile name will be used as node ID, with
273special node ID of C<anon/> will be replaced by a random node ID. 274a slash (C</>) attached.
275
276If the node ID (or profile name) ends with a slash (C</>), then a random
277string is appended to make it unique.
274 278
275=item step 2, bind listener sockets 279=item step 2, bind listener sockets
276 280
277The next step is to look up the binds in the profile, followed by binding 281The next step is to look up the binds in the profile, followed by binding
278aemp protocol listeners on all binds specified (it is possible and valid 282aemp protocol listeners on all binds specified (it is possible and valid
305Example: configure a node using a profile called seed, which is suitable 309Example: configure a node using a profile called seed, which is suitable
306for a seed node as it binds on all local addresses on a fixed port (4040, 310for a seed node as it binds on all local addresses on a fixed port (4040,
307customary for aemp). 311customary for aemp).
308 312
309 # use the aemp commandline utility 313 # use the aemp commandline utility
310 # aemp profile seed nodeid anon/ binds '*:4040' 314 # aemp profile seed binds '*:4040'
311 315
312 # then use it 316 # then use it
313 configure profile => "seed"; 317 configure profile => "seed";
314 318
315 # or simply use aemp from the shell again: 319 # or simply use aemp from the shell again:
385sub _kilme { 389sub _kilme {
386 die "received message on port without callback"; 390 die "received message on port without callback";
387} 391}
388 392
389sub port(;&) { 393sub port(;&) {
390 my $id = "$UNIQ." . ++$ID; 394 my $id = $UNIQ . ++$ID;
391 my $port = "$NODE#$id"; 395 my $port = "$NODE#$id";
392 396
393 rcv $port, shift || \&_kilme; 397 rcv $port, shift || \&_kilme;
394 398
395 $port 399 $port
782} 786}
783 787
784sub spawn(@) { 788sub spawn(@) {
785 my ($nodeid, undef) = split /#/, shift, 2; 789 my ($nodeid, undef) = split /#/, shift, 2;
786 790
787 my $id = "$RUNIQ." . ++$ID; 791 my $id = $RUNIQ . ++$ID;
788 792
789 $_[0] =~ /::/ 793 $_[0] =~ /::/
790 or Carp::croak "spawn init function must be a fully-qualified name, caught"; 794 or Carp::croak "spawn init function must be a fully-qualified name, caught";
791 795
792 snd_to_func $nodeid, "AnyEvent::MP::_spawn" => $id, @_; 796 snd_to_func $nodeid, "AnyEvent::MP::_spawn" => $id, @_;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines