ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent-Fork-RPC/RPC.pm
(Generate patch)

Comparing AnyEvent-Fork-RPC/RPC.pm (file contents):
Revision 1.14 by root, Thu Apr 18 13:11:12 2013 UTC vs.
Revision 1.19 by root, Thu Apr 18 20:27:02 2013 UTC

1=head1 NAME 1=head1 NAME
2 2
3AnyEvent::Fork::RPC - simple RPC extension for AnyEvent::Fork 3AnyEvent::Fork::RPC - simple RPC extension for AnyEvent::Fork
4
5THE 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
373The default server used in the child does all I/O blockingly, and only 377The default server used in the child does all I/O blockingly, and only
374allows a single RPC call to execute concurrently. 378allows a single RPC call to execute concurrently.
375 379
376Setting C<async> to a true value switches to another implementation that 380Setting C<async> to a true value switches to another implementation that
377uses L<AnyEvent> in the child and allows multiple concurrent RPC calls. 381uses L<AnyEvent> in the child and allows multiple concurrent RPC calls (it
382does not support recursion in the event loop however, blocking condvar
383calls will fail).
378 384
379The actual API in the child is documented in the section that describes 385The actual API in the child is documented in the section that describes
380the calling semantics of the returned C<$rpc> function. 386the calling semantics of the returned C<$rpc> function.
381 387
382If you want to pre-load the actual back-end modules to enable memory 388If you want to pre-load the actual back-end modules to enable memory
557 $ww ||= AE::io $fh, 1, $wcb; 563 $ww ||= AE::io $fh, 1, $wcb;
558 }); 564 });
559 565
560 my $guard = Guard::guard { 566 my $guard = Guard::guard {
561 $shutdown = 1; 567 $shutdown = 1;
562 $ww ||= $fh && AE::io $fh, 1, $wcb; 568
569 shutdown $fh, 1 if $fh && !$ww;
563 }; 570 };
564 571
565 my $id; 572 my $id;
566 573
567 $arg{async} 574 $arg{async}
693are queued and the jobs are slow, they will all run concurrently. The 700are queued and the jobs are slow, they will all run concurrently. The
694child must implement some queueing/limiting mechanism if this causes 701child must implement some queueing/limiting mechanism if this causes
695problems. Alternatively, the parent could limit the amount of rpc calls 702problems. Alternatively, the parent could limit the amount of rpc calls
696that are outstanding. 703that are outstanding.
697 704
705Blocking use of condvars is not supported.
706
698Using event-based modules such as L<IO::AIO>, L<Gtk2>, L<Tk> and so on is 707Using event-based modules such as L<IO::AIO>, L<Gtk2>, L<Tk> and so on is
699easy. 708easy.
700 709
701=back 710=back
702 711
765so you might want to look into L<AnyEvent::FDpasser> which can handle the 774so you might want to look into L<AnyEvent::FDpasser> which can handle the
766gory details. 775gory details.
767 776
768=head1 SEE ALSO 777=head1 SEE ALSO
769 778
770L<AnyEvent::Fork> (to create the processes in the first place), 779L<AnyEvent::Fork>, to create the processes in the first place.
780
771L<AnyEvent::Fork::Pool> (to manage whole pools of processes). 781L<AnyEvent::Fork::Pool>, to manage whole pools of processes.
772 782
773=head1 AUTHOR AND CONTACT INFORMATION 783=head1 AUTHOR AND CONTACT INFORMATION
774 784
775 Marc Lehmann <schmorp@schmorp.de> 785 Marc Lehmann <schmorp@schmorp.de>
776 http://software.schmorp.de/pkg/AnyEvent-Fork-RPC 786 http://software.schmorp.de/pkg/AnyEvent-Fork-RPC

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines