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.19 by root, Sat Apr 6 02:31:26 2013 UTC vs.
Revision 1.20 by root, Sat Apr 6 03:35:36 2013 UTC

320 320
321 # everything written 321 # everything written
322 undef $self->[3]; 322 undef $self->[3];
323 323
324 # invoke run callback, if any 324 # invoke run callback, if any
325 $self->[0]->($self->[1]) if $self->[0]; 325 $self->[4]->($self->[1]) if $self->[4];
326 }; 326 };
327 327
328 () # make sure we don't leak the watcher 328 () # make sure we don't leak the watcher
329} 329}
330 330
332 my ($self, $fh, $pid) = @_; 332 my ($self, $fh, $pid) = @_;
333 333
334 AnyEvent::Util::fh_nonblocking $fh, 1; 334 AnyEvent::Util::fh_nonblocking $fh, 1;
335 335
336 $self = bless [ 336 $self = bless [
337 undef, # run callback 337 $pid,
338 $fh, 338 $fh,
339 [], # write queue - strings or fd's 339 [], # write queue - strings or fd's
340 undef, # AE watcher 340 undef, # AE watcher
341 $pid,
342 ], $self; 341 ], $self;
343 342
344 $self 343 $self
345} 344}
346 345
473 ) or die "unable to spawn AnyEvent::Fork server: $!"; 472 ) or die "unable to spawn AnyEvent::Fork server: $!";
474 473
475 $self->_new ($fh, $pid) 474 $self->_new ($fh, $pid)
476} 475}
477 476
477=item $pid = $proc->pid
478
479Returns the process id of the process I<iff it is a direct child of the
480process> running AnyEvent::Fork, and C<undef> otherwise.
481
482Normally, only processes created via C<< AnyEvent::Fork->new_exec >> and
483L<AnyEvent::Fork::Template> are direct children, and you are responsible
484to clean up their zombies when they die.
485
486All other processes are not direct children, and will be cleaned up by
487AnyEvent::Fork.
488
489=cut
490
491sub pid {
492 $_[0][0]
493}
494
478=item $proc = $proc->eval ($perlcode, @args) 495=item $proc = $proc->eval ($perlcode, @args)
479 496
480Evaluates the given C<$perlcode> as ... perl code, while setting C<@_> to 497Evaluates the given C<$perlcode> as ... perl code, while setting C<@_> to
481the strings specified by C<@args>. 498the strings specified by C<@args>.
482 499
628=cut 645=cut
629 646
630sub run { 647sub run {
631 my ($self, $func, $cb) = @_; 648 my ($self, $func, $cb) = @_;
632 649
633 $self->[0] = $cb; 650 $self->[4] = $cb;
634 $self->_cmd (r => $func); 651 $self->_cmd (r => $func);
635} 652}
636 653
637=back 654=back
638 655

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines