… | |
… | |
155 | |
155 | |
156 | use AE (); |
156 | use AE (); |
157 | |
157 | |
158 | use base "Exporter"; |
158 | use base "Exporter"; |
159 | |
159 | |
160 | our $VERSION = 1.21; |
160 | our $VERSION = 1.24; |
161 | |
161 | |
162 | our @EXPORT = qw( |
162 | our @EXPORT = qw( |
163 | NODE $NODE *SELF node_of after |
163 | NODE $NODE *SELF node_of after |
164 | configure |
164 | configure |
165 | snd rcv mon mon_guard kil psub peval spawn cal |
165 | snd rcv mon mon_guard kil psub peval spawn cal |
… | |
… | |
406 | if (ref $_[0]) { |
406 | if (ref $_[0]) { |
407 | if (my $self = $PORT_DATA{$portid}) { |
407 | if (my $self = $PORT_DATA{$portid}) { |
408 | "AnyEvent::MP::Port" eq ref $self |
408 | "AnyEvent::MP::Port" eq ref $self |
409 | or Carp::croak "$port: rcv can only be called on message matching ports, caught"; |
409 | or Carp::croak "$port: rcv can only be called on message matching ports, caught"; |
410 | |
410 | |
411 | $self->[2] = shift; |
411 | $self->[0] = shift; |
412 | } else { |
412 | } else { |
413 | my $cb = shift; |
413 | my $cb = shift; |
414 | $PORT{$portid} = sub { |
414 | $PORT{$portid} = sub { |
415 | local $SELF = $port; |
415 | local $SELF = $port; |
416 | eval { &$cb }; _self_die if $@; |
416 | eval { &$cb }; _self_die if $@; |
417 | }; |
417 | }; |
418 | } |
418 | } |
419 | } elsif (defined $_[0]) { |
419 | } elsif (defined $_[0]) { |
420 | my $self = $PORT_DATA{$portid} ||= do { |
420 | my $self = $PORT_DATA{$portid} ||= do { |
421 | my $self = bless [$PORT{$port} || sub { }, { }, $port], "AnyEvent::MP::Port"; |
421 | my $self = bless [$PORT{$portid} || sub { }, { }, $port], "AnyEvent::MP::Port"; |
422 | |
422 | |
423 | $PORT{$portid} = sub { |
423 | $PORT{$portid} = sub { |
424 | local $SELF = $port; |
424 | local $SELF = $port; |
425 | |
425 | |
426 | if (my $cb = $self->[1]{$_[0]}) { |
426 | if (my $cb = $self->[1]{$_[0]}) { |
… | |
… | |
650 | |
650 | |
651 | =item kil $port[, @reason] |
651 | =item kil $port[, @reason] |
652 | |
652 | |
653 | Kill the specified port with the given C<@reason>. |
653 | Kill the specified port with the given C<@reason>. |
654 | |
654 | |
655 | If no C<@reason> is specified, then the port is killed "normally" (ports |
655 | If no C<@reason> is specified, then the port is killed "normally" - |
656 | monitoring other ports will not necessarily die because a port dies |
656 | monitor callback will be invoked, but the kil will not cause linked ports |
657 | "normally"). |
657 | (C<mon $mport, $lport> form) to get killed. |
658 | |
658 | |
659 | Otherwise, linked ports get killed with the same reason (second form of |
659 | If a C<@reason> is specified, then linked ports (C<mon $mport, $lport> |
660 | C<mon>, see above). |
660 | form) get killed with the same reason. |
661 | |
661 | |
662 | Runtime errors while evaluating C<rcv> callbacks or inside C<psub> blocks |
662 | Runtime errors while evaluating C<rcv> callbacks or inside C<psub> blocks |
663 | will be reported as reason C<< die => $@ >>. |
663 | will be reported as reason C<< die => $@ >>. |
664 | |
664 | |
665 | Transport/communication errors are reported as C<< transport_error => |
665 | Transport/communication errors are reported as C<< transport_error => |
… | |
… | |
979 | L<AnyEvent::MP::Kernel> - more, lower-level, stuff. |
979 | L<AnyEvent::MP::Kernel> - more, lower-level, stuff. |
980 | |
980 | |
981 | L<AnyEvent::MP::Global> - network maintainance and port groups, to find |
981 | L<AnyEvent::MP::Global> - network maintainance and port groups, to find |
982 | your applications. |
982 | your applications. |
983 | |
983 | |
|
|
984 | L<AnyEvent::MP::DataConn> - establish data connections between nodes. |
|
|
985 | |
984 | L<AnyEvent::MP::LogCatcher> - simple service to display log messages from |
986 | L<AnyEvent::MP::LogCatcher> - simple service to display log messages from |
985 | all nodes. |
987 | all nodes. |
986 | |
988 | |
987 | L<AnyEvent>. |
989 | L<AnyEvent>. |
988 | |
990 | |