… | |
… | |
11 | ->new |
11 | ->new |
12 | ->require ("MyModule") |
12 | ->require ("MyModule") |
13 | ->AnyEvent::Fork::RPC::run ( |
13 | ->AnyEvent::Fork::RPC::run ( |
14 | "MyModule::server", |
14 | "MyModule::server", |
15 | ); |
15 | ); |
|
|
16 | |
|
|
17 | use AnyEvent; |
16 | |
18 | |
17 | my $cv = AE::cv; |
19 | my $cv = AE::cv; |
18 | |
20 | |
19 | $rpc->(1, 2, 3, sub { |
21 | $rpc->(1, 2, 3, sub { |
20 | print "MyModule::server returned @_\n"; |
22 | print "MyModule::server returned @_\n"; |
… | |
… | |
372 | |
374 | |
373 | The default server used in the child does all I/O blockingly, and only |
375 | The default server used in the child does all I/O blockingly, and only |
374 | allows a single RPC call to execute concurrently. |
376 | allows a single RPC call to execute concurrently. |
375 | |
377 | |
376 | Setting C<async> to a true value switches to another implementation that |
378 | Setting C<async> to a true value switches to another implementation that |
377 | uses L<AnyEvent> in the child and allows multiple concurrent RPC calls. |
379 | uses L<AnyEvent> in the child and allows multiple concurrent RPC calls (it |
|
|
380 | does not support recursion in the event loop however, blocking condvar |
|
|
381 | calls will fail). |
378 | |
382 | |
379 | The actual API in the child is documented in the section that describes |
383 | The actual API in the child is documented in the section that describes |
380 | the calling semantics of the returned C<$rpc> function. |
384 | the calling semantics of the returned C<$rpc> function. |
381 | |
385 | |
382 | If you want to pre-load the actual back-end modules to enable memory |
386 | If you want to pre-load the actual back-end modules to enable memory |
… | |
… | |
693 | are queued and the jobs are slow, they will all run concurrently. The |
697 | are queued and the jobs are slow, they will all run concurrently. The |
694 | child must implement some queueing/limiting mechanism if this causes |
698 | child must implement some queueing/limiting mechanism if this causes |
695 | problems. Alternatively, the parent could limit the amount of rpc calls |
699 | problems. Alternatively, the parent could limit the amount of rpc calls |
696 | that are outstanding. |
700 | that are outstanding. |
697 | |
701 | |
|
|
702 | Blocking use of condvars is not supported. |
|
|
703 | |
698 | Using event-based modules such as L<IO::AIO>, L<Gtk2>, L<Tk> and so on is |
704 | Using event-based modules such as L<IO::AIO>, L<Gtk2>, L<Tk> and so on is |
699 | easy. |
705 | easy. |
700 | |
706 | |
701 | =back |
707 | =back |
702 | |
708 | |
… | |
… | |
765 | so you might want to look into L<AnyEvent::FDpasser> which can handle the |
771 | so you might want to look into L<AnyEvent::FDpasser> which can handle the |
766 | gory details. |
772 | gory details. |
767 | |
773 | |
768 | =head1 SEE ALSO |
774 | =head1 SEE ALSO |
769 | |
775 | |
770 | L<AnyEvent::Fork> (to create the processes in the first place), |
776 | L<AnyEvent::Fork>, to create the processes in the first place. |
|
|
777 | |
771 | L<AnyEvent::Fork::Pool> (to manage whole pools of processes). |
778 | L<AnyEvent::Fork::Pool>, to manage whole pools of processes. |
772 | |
779 | |
773 | =head1 AUTHOR AND CONTACT INFORMATION |
780 | =head1 AUTHOR AND CONTACT INFORMATION |
774 | |
781 | |
775 | Marc Lehmann <schmorp@schmorp.de> |
782 | Marc Lehmann <schmorp@schmorp.de> |
776 | http://software.schmorp.de/pkg/AnyEvent-Fork-RPC |
783 | http://software.schmorp.de/pkg/AnyEvent-Fork-RPC |