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

Comparing cvsroot/AnyEvent-Fork/Fork.pm (file contents):
Revision 1.31 by root, Sat Apr 6 09:29:26 2013 UTC vs.
Revision 1.32 by root, Sat Apr 6 09:30:26 2013 UTC

152 152
153 # now $master_filehandle is connected to the 153 # now $master_filehandle is connected to the
154 # $slave_filehandle in the new process. 154 # $slave_filehandle in the new process.
155 }); 155 });
156 156
157MyModule might look like this: 157C<MyModule> might look like this:
158 158
159 package MyModule; 159 package MyModule;
160 160
161 sub worker { 161 sub worker {
162 my ($slave_filehandle) = @_; 162 my ($slave_filehandle) = @_;
185 } 185 }
186 186
187 # now do other things - maybe use the filehandle provided by run 187 # now do other things - maybe use the filehandle provided by run
188 # to wait for the processes to die. or whatever. 188 # to wait for the processes to die. or whatever.
189 189
190My::Server might look like this: 190C<My::Server> might look like this:
191 191
192 package My::Server; 192 package My::Server;
193 193
194 sub run { 194 sub run {
195 my ($slave, $listener, $id) = @_; 195 my ($slave, $listener, $id) = @_;
203 } 203 }
204 } 204 }
205 205
206=head2 use AnyEvent::Fork as a faster fork+exec 206=head2 use AnyEvent::Fork as a faster fork+exec
207 207
208This runs /bin/echo hi, with stdout redirected to /tmp/log and stderr to 208This runs C</bin/echo hi>, with stdandard output redirected to /tmp/log
209the communications socket. It is usually faster than fork+exec, but still 209and standard error redirected to the communications socket. It is usually
210let's you prepare the environment. 210faster than fork+exec, but still lets you prepare the environment.
211 211
212 open my $output, ">/tmp/log" or die "$!"; 212 open my $output, ">/tmp/log" or die "$!";
213 213
214 AnyEvent::Fork 214 AnyEvent::Fork
215 ->new 215 ->new

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines