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

Comparing AnyEvent-Fork/Fork.pm (file contents):
Revision 1.64 by root, Wed Nov 26 13:37:40 2014 UTC vs.
Revision 1.66 by root, Sat Jun 20 13:24:54 2015 UTC

200 200
201 sub worker { 201 sub worker {
202 my ($slave_filehandle) = @_; 202 my ($slave_filehandle) = @_;
203 203
204 # now $slave_filehandle is connected to the $master_filehandle 204 # now $slave_filehandle is connected to the $master_filehandle
205 # in the original prorcess. have fun! 205 # in the original process. have fun!
206 } 206 }
207 207
208=head2 Create a pool of server processes all accepting on the same socket. 208=head2 Create a pool of server processes all accepting on the same socket.
209 209
210 # create listener socket 210 # create listener socket
673 my %env = %ENV; 673 my %env = %ENV;
674 $env{PERL5LIB} = join +($^O eq "MSWin32" ? ";" : ":"), grep !ref, @INC; 674 $env{PERL5LIB} = join +($^O eq "MSWin32" ? ";" : ":"), grep !ref, @INC;
675 675
676 my $pid = Proc::FastSpawn::spawn ( 676 my $pid = Proc::FastSpawn::spawn (
677 $PERL, 677 $PERL,
678 ["perl", "-MAnyEvent::Fork::Serve", "-e", "AnyEvent::Fork::Serve::me", fileno $slave, $$], 678 [$PERL, "-MAnyEvent::Fork::Serve", "-e", "AnyEvent::Fork::Serve::me", fileno $slave, $$],
679 [map "$_=$env{$_}", keys %env], 679 [map "$_=$env{$_}", keys %env],
680 ) or die "unable to spawn AnyEvent::Fork server: $!"; 680 ) or die "unable to spawn AnyEvent::Fork server: $!";
681 681
682 $self->_new ($fh, $pid) 682 $self->_new ($fh, $pid)
683} 683}
719it via C<run>. This also gives you access to any arguments passed via the 719it via C<run>. This also gives you access to any arguments passed via the
720C<send_xxx> methods, such as file handles. See the L<use AnyEvent::Fork as 720C<send_xxx> methods, such as file handles. See the L<use AnyEvent::Fork as
721a faster fork+exec> example to see it in action. 721a faster fork+exec> example to see it in action.
722 722
723Returns the process object for easy chaining of method calls. 723Returns the process object for easy chaining of method calls.
724
725It's common to want to call an iniitalisation function with some
726arguments. Make sure you actually pass C<@_> to that function (for example
727by using C<&name> syntax), and do not just specify a function name:
728
729 $proc->eval ('&MyModule::init', $string1, $string2);
724 730
725=cut 731=cut
726 732
727sub eval { 733sub eval {
728 my ($self, $code, @args) = @_; 734 my ($self, $code, @args) = @_;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines