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.29 by root, Sat Apr 6 09:15:49 2013 UTC vs.
Revision 1.31 by root, Sat Apr 6 09:29: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
157 # MyModule::worker might look like this 157MyModule might look like this:
158
159 package MyModule;
160
158 sub MyModule::worker { 161 sub worker {
159 my ($slave_filehandle) = @_; 162 my ($slave_filehandle) = @_;
160 163
161 # now $slave_filehandle is connected to the $master_filehandle 164 # now $slave_filehandle is connected to the $master_filehandle
162 # in the original prorcess. have fun! 165 # in the original prorcess. have fun!
163 } 166 }
182 } 185 }
183 186
184 # now do other things - maybe use the filehandle provided by run 187 # now do other things - maybe use the filehandle provided by run
185 # to wait for the processes to die. or whatever. 188 # to wait for the processes to die. or whatever.
186 189
187 # My::Server::run might look like this 190My::Server might look like this:
188 sub My::Server::run { 191
192 package My::Server;
193
194 sub run {
189 my ($slave, $listener, $id) = @_; 195 my ($slave, $listener, $id) = @_;
190 196
191 close $slave; # we do not use the socket, so close it to save resources 197 close $slave; # we do not use the socket, so close it to save resources
192 198
193 # we could go ballistic and use e.g. AnyEvent here, or IO::AIO, 199 # we could go ballistic and use e.g. AnyEvent here, or IO::AIO,
560Normally, only processes created via C<< AnyEvent::Fork->new_exec >> and 566Normally, only processes created via C<< AnyEvent::Fork->new_exec >> and
561L<AnyEvent::Fork::Template> are direct children, and you are responsible 567L<AnyEvent::Fork::Template> are direct children, and you are responsible
562to clean up their zombies when they die. 568to clean up their zombies when they die.
563 569
564All other processes are not direct children, and will be cleaned up by 570All other processes are not direct children, and will be cleaned up by
565AnyEvent::Fork. 571AnyEvent::Fork itself.
566 572
567=cut 573=cut
568 574
569sub pid { 575sub pid {
570 $_[0][0] 576 $_[0][0]

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines