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.26 by root, Sun Apr 28 14:27:11 2013 UTC vs.
Revision 1.27 by root, Sun Apr 28 14:34:40 2013 UTC

2 2
3AnyEvent::Fork::RPC - simple RPC extension for AnyEvent::Fork 3AnyEvent::Fork::RPC - simple RPC extension for AnyEvent::Fork
4 4
5=head1 SYNOPSIS 5=head1 SYNOPSIS
6 6
7 use AnyEvent::Fork;
7 use AnyEvent::Fork::RPC; 8 use AnyEvent::Fork::RPC;
8 # use AnyEvent::Fork is not needed
9 9
10 my $rpc = AnyEvent::Fork 10 my $rpc = AnyEvent::Fork
11 ->new 11 ->new
12 ->require ("MyModule") 12 ->require ("MyModule")
13 ->AnyEvent::Fork::RPC::run ( 13 ->AnyEvent::Fork::RPC::run (
37concurrently in the child, using AnyEvent. 37concurrently in the child, using AnyEvent.
38 38
39It also implements an asynchronous event mechanism from the child to the 39It also implements an asynchronous event mechanism from the child to the
40parent, that could be used for progress indications or other information. 40parent, that could be used for progress indications or other information.
41 41
42Loading this module also always loads L<AnyEvent::Fork>, so you can make a
43separate C<use AnyEvent::Fork> if you wish, but you don't have to.
44
45=head1 EXAMPLES 42=head1 EXAMPLES
46 43
47=head2 Example 1: Synchronous Backend 44=head2 Example 1: Synchronous Backend
48 45
49Here is a simple example that implements a backend that executes C<unlink> 46Here is a simple example that implements a backend that executes C<unlink>
52silly, but illustrates the use of events. 49silly, but illustrates the use of events.
53 50
54First the parent process: 51First the parent process:
55 52
56 use AnyEvent; 53 use AnyEvent;
54 use AnyEvent::Fork;
57 use AnyEvent::Fork::RPC; 55 use AnyEvent::Fork::RPC;
58 56
59 my $done = AE::cv; 57 my $done = AE::cv;
60 58
61 my $rpc = AnyEvent::Fork 59 my $rpc = AnyEvent::Fork
192so silly anymore. 190so silly anymore.
193 191
194Without further ado, here is the code: 192Without further ado, here is the code:
195 193
196 use AnyEvent; 194 use AnyEvent;
195 use AnyEvent::Fork;
197 use AnyEvent::Fork::RPC; 196 use AnyEvent::Fork::RPC;
198 197
199 my $done = AE::cv; 198 my $done = AE::cv;
200 199
201 my $rpc = AnyEvent::Fork 200 my $rpc = AnyEvent::Fork
304 303
305use Errno (); 304use Errno ();
306use Guard (); 305use Guard ();
307 306
308use AnyEvent; 307use AnyEvent;
309# explicit version on next line, as some cpan-testers test with the 0.1 version,
310# ignoring dependencies, and this line will at least give a clear indication of that.
311use AnyEvent::Fork 0.6; # we don't actually depend on it, this is for convenience
312 308
313our $VERSION = 1.1; 309our $VERSION = 1.1;
314 310
315=item my $rpc = AnyEvent::Fork::RPC::run $fork, $function, [key => value...] 311=item my $rpc = AnyEvent::Fork::RPC::run $fork, $function, [key => value...]
316 312
729half it has passed earlier. 725half it has passed earlier.
730 726
731Here is some (untested) pseudocode to that effect: 727Here is some (untested) pseudocode to that effect:
732 728
733 use AnyEvent::Util; 729 use AnyEvent::Util;
730 use AnyEvent::Fork;
734 use AnyEvent::Fork::RPC; 731 use AnyEvent::Fork::RPC;
735 use IO::FDPass; 732 use IO::FDPass;
736 733
737 my ($s1, $s2) = AnyEvent::Util::portable_socketpair; 734 my ($s1, $s2) = AnyEvent::Util::portable_socketpair;
738 735
785 782
786=head1 SEE ALSO 783=head1 SEE ALSO
787 784
788L<AnyEvent::Fork>, to create the processes in the first place. 785L<AnyEvent::Fork>, to create the processes in the first place.
789 786
790L<AnyEvent::Fork::Remote>, like above, but helpful for remote processes. 787L<AnyEvent::Fork::Remote>, likewise, but helpful for remote processes.
791 788
792L<AnyEvent::Fork::Pool>, to manage whole pools of processes. 789L<AnyEvent::Fork::Pool>, to manage whole pools of processes.
793 790
794=head1 AUTHOR AND CONTACT INFORMATION 791=head1 AUTHOR AND CONTACT INFORMATION
795 792

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines