… | |
… | |
546 | sub mon { |
546 | sub mon { |
547 | my ($noderef, $port) = split /#/, shift, 2; |
547 | my ($noderef, $port) = split /#/, shift, 2; |
548 | |
548 | |
549 | my $node = $NODE{$noderef} || add_node $noderef; |
549 | my $node = $NODE{$noderef} || add_node $noderef; |
550 | |
550 | |
551 | my $cb = @_ ? $_[0] : $SELF || Carp::croak 'mon: called with one argument only, but $SELF not set,'; |
551 | my $cb = @_ ? shift : $SELF || Carp::croak 'mon: called with one argument only, but $SELF not set,'; |
552 | |
552 | |
553 | unless (ref $cb) { |
553 | unless (ref $cb) { |
554 | if (@_) { |
554 | if (@_) { |
555 | # send a kill info message |
555 | # send a kill info message |
556 | my (@msg) = @_; |
556 | my (@msg) = ($cb, @_); |
557 | $cb = sub { snd @msg, @_ }; |
557 | $cb = sub { snd @msg, @_ }; |
558 | } else { |
558 | } else { |
559 | # simply kill other port |
559 | # simply kill other port |
560 | my $port = $cb; |
560 | my $port = $cb; |
561 | $cb = sub { kil $port, @_ if @_ }; |
561 | $cb = sub { kil $port, @_ if @_ }; |
… | |
… | |
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 function 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>). To specify a function in the main |
|
|
626 | program, use C<::name>. |
626 | |
627 | |
627 | If the function doesn't exist, then the node tries to C<require> |
628 | 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. |
629 | 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 |
630 | C<MyApp::Chat::Server>, C<MyApp::Chat>, C<MyApp>) until the function |
630 | exists or it runs out of package names. |
631 | exists or it runs out of package names. |