… | |
… | |
82 | |
82 | |
83 | Ports are represented by (printable) strings called "port IDs". |
83 | Ports 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 | |
87 | A port ID is the concatenation of a node ID, a hash-mark (C<#>) as |
87 | A port ID is the concatenation of a node ID, a hash-mark (C<#>) |
88 | separator, and a port name (a printable string of unspecified format). |
88 | as separator, and a port name (a printable string of unspecified |
|
|
89 | format created by AnyEvent::MP). |
89 | |
90 | |
90 | =item node |
91 | =item node |
91 | |
92 | |
92 | A node is a single process containing at least one port - the node port, |
93 | A node is a single process containing at least one port - the node port, |
93 | which enables nodes to manage each other remotely, and to create new |
94 | which enables nodes to manage each other remotely, and to create new |
… | |
… | |
388 | sub _kilme { |
389 | sub _kilme { |
389 | die "received message on port without callback"; |
390 | die "received message on port without callback"; |
390 | } |
391 | } |
391 | |
392 | |
392 | sub port(;&) { |
393 | sub port(;&) { |
393 | my $id = "$UNIQ." . ++$ID; |
394 | my $id = $UNIQ . ++$ID; |
394 | my $port = "$NODE#$id"; |
395 | my $port = "$NODE#$id"; |
395 | |
396 | |
396 | rcv $port, shift || \&_kilme; |
397 | rcv $port, shift || \&_kilme; |
397 | |
398 | |
398 | $port |
399 | $port |
… | |
… | |
785 | } |
786 | } |
786 | |
787 | |
787 | sub spawn(@) { |
788 | sub spawn(@) { |
788 | my ($nodeid, undef) = split /#/, shift, 2; |
789 | my ($nodeid, undef) = split /#/, shift, 2; |
789 | |
790 | |
790 | my $id = "$RUNIQ." . ++$ID; |
791 | my $id = $RUNIQ . ++$ID; |
791 | |
792 | |
792 | $_[0] =~ /::/ |
793 | $_[0] =~ /::/ |
793 | 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"; |
794 | |
795 | |
795 | snd_to_func $nodeid, "AnyEvent::MP::_spawn" => $id, @_; |
796 | snd_to_func $nodeid, "AnyEvent::MP::_spawn" => $id, @_; |