… | |
… | |
628 | A common idiom is to pass a local port, immediately monitor the spawned |
628 | A common idiom is to pass a local port, immediately monitor the spawned |
629 | port, and in the remote init function, immediately monitor the passed |
629 | port, and in the remote init function, immediately monitor the passed |
630 | local port. This two-way monitoring ensures that both ports get cleaned up |
630 | local port. This two-way monitoring ensures that both ports get cleaned up |
631 | when there is a problem. |
631 | when there is a problem. |
632 | |
632 | |
|
|
633 | C<spawn> guarantees that the C<$initfunc> has no visible effects on the |
|
|
634 | caller before C<spawn> returns (by delaying invocation when spawn is |
|
|
635 | called for the local node). |
|
|
636 | |
633 | Example: spawn a chat server port on C<$othernode>. |
637 | Example: spawn a chat server port on C<$othernode>. |
634 | |
638 | |
635 | # this node, executed from within a port context: |
639 | # this node, executed from within a port context: |
636 | my $server = spawn $othernode, "MyApp::Chat::Server::connect", $SELF; |
640 | my $server = spawn $othernode, "MyApp::Chat::Server::connect", $SELF; |
637 | mon $server; |
641 | mon $server; |