1 | =head1 NAME |
1 | =head1 NAME |
2 | |
2 | |
3 | AnyEvent::MP - multi-processing/message-passing framework |
3 | AnyEvent::MP - erlang-style multi-processing/message-passing framework |
4 | |
4 | |
5 | =head1 SYNOPSIS |
5 | =head1 SYNOPSIS |
6 | |
6 | |
7 | use AnyEvent::MP; |
7 | use AnyEvent::MP; |
8 | |
8 | |
… | |
… | |
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 | # monitoring |
35 | # monitoring |
36 | mon $port, $cb->(@msg) # callback is invoked on death |
36 | mon $localport, $cb->(@msg) # callback is invoked on death |
37 | mon $port, $otherport # kill otherport on abnormal death |
37 | mon $localport, $otherport # kill otherport on abnormal death |
38 | mon $port, $otherport, @msg # send message on death |
38 | mon $localport, $otherport, @msg # send message on death |
39 | |
39 | |
40 | =head1 CURRENT STATUS |
40 | =head1 CURRENT STATUS |
41 | |
41 | |
42 | bin/aemp - stable. |
42 | bin/aemp - stable. |
43 | AnyEvent::MP - stable API, should work. |
43 | AnyEvent::MP - stable API, should work. |
… | |
… | |
148 | our $VERSION = $AnyEvent::MP::Kernel::VERSION; |
148 | our $VERSION = $AnyEvent::MP::Kernel::VERSION; |
149 | |
149 | |
150 | our @EXPORT = qw( |
150 | our @EXPORT = qw( |
151 | NODE $NODE *SELF node_of after |
151 | NODE $NODE *SELF node_of after |
152 | configure |
152 | configure |
153 | snd rcv mon mon_guard kil reg psub spawn cal |
153 | snd rcv mon mon_guard kil psub spawn cal |
154 | port |
154 | port |
155 | ); |
155 | ); |
156 | |
156 | |
157 | our $SELF; |
157 | our $SELF; |
158 | |
158 | |
… | |
… | |
565 | } |
565 | } |
566 | |
566 | |
567 | $node->monitor ($port, $cb); |
567 | $node->monitor ($port, $cb); |
568 | |
568 | |
569 | defined wantarray |
569 | defined wantarray |
|
|
570 | and $cb += 0 |
570 | and AnyEvent::Util::guard { $node->unmonitor ($port, $cb) } |
571 | and AnyEvent::Util::guard { $node->unmonitor ($port, $cb) } |
571 | } |
572 | } |
572 | |
573 | |
573 | =item $guard = mon_guard $port, $ref, $ref... |
574 | =item $guard = mon_guard $port, $ref, $ref... |
574 | |
575 | |