function run()
{
if (isset($this->_debug)) {
- echo $this->name() . " - debugging output enabled.\n";
+ echo $this->name() . " - Debugging output enabled.\n";
}
do {
if ($pid) {
// Parent
+
if (isset($this->_debug)) {
echo $this->name() .
- " (parent) forked new child - pid $pid.\n";
+ " - Forked new child - pid $pid.\n";
}
// Child
// Do something with each object
+
$this->childTask($o);
exit();
}
// Remove child from ps list as it finishes
+
while (($c = pcntl_wait($status, WNOHANG OR WUNTRACED)) > 0) {
if (isset($this->_debug)) {
- echo $this->name() . " child $c finished.\n";
+ echo $this->name() . " - Child $c finished.\n";
}
$this->removePs($this->_children, $c);
}
// Wait! We have too many damn kids.
+
if (sizeof($this->_children) >= $this->_max_children) {
if (isset($this->_debug)) {
while (($c = pcntl_wait($status, WUNTRACED)) > 0) {
if (isset($this->_debug)) {
- echo $this->name() . " child $c finished.\n";
+ echo $this->name() . " - Child $c finished.\n";
}
$this->removePs($this->_children, $c);