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