… | |
… | |
619 | |
619 | |
620 | The port ID of the newly created port is return immediately, and it is |
620 | The port ID of the newly created port is return immediately, and it is |
621 | permissible to immediately start sending messages or monitor the port. |
621 | permissible to immediately start sending messages or monitor the port. |
622 | |
622 | |
623 | After the port has been created, the init function is |
623 | After the port has been created, the init function is |
624 | called. This fucntion must be a fully-qualified function name |
624 | called. This function must be a fully-qualified function name |
625 | (e.g. C<MyApp::Chat::Server::init>). |
625 | (e.g. C<MyApp::Chat::Server::init>). |
626 | |
626 | |
627 | If the function doesn't exist, then the node tries to C<require> |
627 | If the function doesn't exist, then the node tries to C<require> |
628 | the package, then the package above the package and so on (e.g. |
628 | the package, then the package above the package and so on (e.g. |
629 | C<MyApp::Chat::Server>, C<MyApp::Chat>, C<MyApp>) until the function |
629 | C<MyApp::Chat::Server>, C<MyApp::Chat>, C<MyApp>) until the function |
… | |
… | |
669 | sub spawn(@) { |
669 | sub spawn(@) { |
670 | my ($noderef, undef) = split /#/, shift, 2; |
670 | my ($noderef, undef) = split /#/, shift, 2; |
671 | |
671 | |
672 | my $id = "$RUNIQ." . $ID++; |
672 | my $id = "$RUNIQ." . $ID++; |
673 | |
673 | |
|
|
674 | $_[0] =~ /::/ |
|
|
675 | or Carp::croak "spawn init function must be a fully-qualified name, caught"; |
|
|
676 | |
674 | ($NODE{$noderef} || add_node $noderef) |
677 | ($NODE{$noderef} || add_node $noderef) |
675 | ->send (["", "AnyEvent::MP::_spawn" => $id, @_]); |
678 | ->send (["", "AnyEvent::MP::_spawn" => $id, @_]); |
676 | |
679 | |
677 | "$noderef#$id" |
680 | "$noderef#$id" |
678 | } |
681 | } |