… | |
… | |
126 | use base "Exporter"; |
126 | use base "Exporter"; |
127 | |
127 | |
128 | our $VERSION = $AnyEvent::MP::Kernel::VERSION; |
128 | our $VERSION = $AnyEvent::MP::Kernel::VERSION; |
129 | |
129 | |
130 | our @EXPORT = qw( |
130 | our @EXPORT = qw( |
131 | NODE $NODE *SELF node_of _any_ |
131 | NODE $NODE *SELF node_of after |
132 | resolve_node initialise_node |
132 | resolve_node initialise_node |
133 | snd rcv mon kil reg psub spawn |
133 | snd rcv mon kil reg psub spawn |
134 | port |
134 | port |
135 | ); |
135 | ); |
136 | |
136 | |
… | |
… | |
682 | snd_to_func $noderef, "AnyEvent::MP::_spawn" => $id, @_; |
682 | snd_to_func $noderef, "AnyEvent::MP::_spawn" => $id, @_; |
683 | |
683 | |
684 | "$noderef#$id" |
684 | "$noderef#$id" |
685 | } |
685 | } |
686 | |
686 | |
|
|
687 | =item after $timeout, @msg |
|
|
688 | |
|
|
689 | =item after $timeout, $callback |
|
|
690 | |
|
|
691 | Either sends the given message, or call the given callback, after the |
|
|
692 | specified number of seconds. |
|
|
693 | |
|
|
694 | This is simply a utility function that come sin handy at times. |
|
|
695 | |
|
|
696 | =cut |
|
|
697 | |
|
|
698 | sub after($@) { |
|
|
699 | my ($timeout, @action) = @_; |
|
|
700 | |
|
|
701 | my $t; $t = AE::timer $timeout, 0, sub { |
|
|
702 | undef $t; |
|
|
703 | ref $action[0] |
|
|
704 | ? $action[0]() |
|
|
705 | : snd @action; |
|
|
706 | }; |
|
|
707 | } |
|
|
708 | |
687 | =back |
709 | =back |
688 | |
710 | |
689 | =head1 AnyEvent::MP vs. Distributed Erlang |
711 | =head1 AnyEvent::MP vs. Distributed Erlang |
690 | |
712 | |
691 | AnyEvent::MP got lots of its ideas from distributed Erlang (Erlang node |
713 | AnyEvent::MP got lots of its ideas from distributed Erlang (Erlang node |