… | |
… | |
30 | rcv $port, pong => sub { warn "pong received\n" }; |
30 | rcv $port, pong => sub { warn "pong received\n" }; |
31 | |
31 | |
32 | # create a port on another node |
32 | # create a port on another node |
33 | my $port = spawn $node, $initfunc, @initdata; |
33 | my $port = spawn $node, $initfunc, @initdata; |
34 | |
34 | |
35 | # destroy a prot again |
35 | # destroy a port again |
36 | kil $port; # "normal" kill |
36 | kil $port; # "normal" kill |
37 | kil $port, my_error => "everything is broken"; # error kill |
37 | kil $port, my_error => "everything is broken"; # error kill |
38 | |
38 | |
39 | # monitoring |
39 | # monitoring |
40 | mon $localport, $cb->(@msg) # callback is invoked on death |
40 | mon $localport, $cb->(@msg) # callback is invoked on death |
… | |
… | |
155 | |
155 | |
156 | use AE (); |
156 | use AE (); |
157 | |
157 | |
158 | use base "Exporter"; |
158 | use base "Exporter"; |
159 | |
159 | |
160 | our $VERSION = 1.26; |
160 | our $VERSION = 1.29; |
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 |
… | |
… | |
495 | Remembers C<$SELF> and creates a closure out of the BLOCK. When the |
495 | Remembers C<$SELF> and creates a closure out of the BLOCK. When the |
496 | closure is executed, sets up the environment in the same way as in C<rcv> |
496 | closure is executed, sets up the environment in the same way as in C<rcv> |
497 | callbacks, i.e. runtime errors will cause the port to get C<kil>ed. |
497 | callbacks, i.e. runtime errors will cause the port to get C<kil>ed. |
498 | |
498 | |
499 | The effect is basically as if it returned C<< sub { peval $SELF, sub { |
499 | The effect is basically as if it returned C<< sub { peval $SELF, sub { |
500 | BLOCK } } >>. |
500 | BLOCK }, @_ } >>. |
501 | |
501 | |
502 | This is useful when you register callbacks from C<rcv> callbacks: |
502 | This is useful when you register callbacks from C<rcv> callbacks: |
503 | |
503 | |
504 | rcv delayed_reply => sub { |
504 | rcv delayed_reply => sub { |
505 | my ($delay, @reply) = @_; |
505 | my ($delay, @reply) = @_; |
… | |
… | |
979 | |
979 | |
980 | L<AnyEvent::MP::Intro> - a gentle introduction. |
980 | L<AnyEvent::MP::Intro> - a gentle introduction. |
981 | |
981 | |
982 | L<AnyEvent::MP::Kernel> - more, lower-level, stuff. |
982 | L<AnyEvent::MP::Kernel> - more, lower-level, stuff. |
983 | |
983 | |
984 | L<AnyEvent::MP::Global> - network maintainance and port groups, to find |
984 | L<AnyEvent::MP::Global> - network maintenance and port groups, to find |
985 | your applications. |
985 | your applications. |
986 | |
986 | |
987 | L<AnyEvent::MP::DataConn> - establish data connections between nodes. |
987 | L<AnyEvent::MP::DataConn> - establish data connections between nodes. |
988 | |
988 | |
989 | L<AnyEvent::MP::LogCatcher> - simple service to display log messages from |
989 | L<AnyEvent::MP::LogCatcher> - simple service to display log messages from |