]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/parallelizingdaemon.php
Misses this file to merge. I like the comments.
[quix0rs-gnu-social.git] / lib / parallelizingdaemon.php
index 5ecfd98f3326901fc9ad626220e20e6818ca4b2e..517115de0497521448c5abdd214f11bee9a29f3e 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * Laconica, the distributed open-source microblogging tool
+ * StatusNet, the distributed open-source microblogging tool
  *
  * Base class for making daemons that can do several tasks in parallel.
  *
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
  * @category  Daemon
- * @package   Laconica
- * @author    Zach Copley <zach@controlyourself.ca>
- * @author    Evan Prodromou <evan@controlyourself.ca>
- * @copyright 2009 Control Yourself, Inc.
+ * @package   StatusNet
+ * @author    Zach Copley <zach@status.net>
+ * @author    Evan Prodromou <evan@status.net>
+ * @copyright 2009 StatusNet, Inc.
  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link      http://laconi.ca/
+ * @link      http://status.net/
  */
 
-if (!defined('LACONICA')) {
+if (!defined('STATUSNET') && !defined('LACONICA')) {
     exit(1);
 }
 
@@ -38,11 +38,11 @@ declare(ticks = 1);
  * Daemon able to spawn multiple child processes to do work in parallel
  *
  * @category Daemon
- * @package  Laconica
- * @author   Zach Copley <zach@controlyourself.ca>
- * @author   Evan Prodromou <evan@controlyourself.ca>
+ * @package  StatusNet
+ * @author   Zach Copley <zach@status.net>
+ * @author   Evan Prodromou <evan@status.net>
  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
- * @link     http://laconi.ca/
+ * @link     http://status.net/
  */
 
 class ParallelizingDaemon extends Daemon
@@ -87,7 +87,7 @@ class ParallelizingDaemon extends Daemon
     function run()
     {
         if (isset($this->_debug)) {
-            echo $this->name() . " - debugging output enabled.\n";
+            echo $this->name() . " - Debugging output enabled.\n";
         }
 
         do {
@@ -107,9 +107,10 @@ class ParallelizingDaemon extends Daemon
                 if ($pid) {
 
                     // Parent
+
                     if (isset($this->_debug)) {
                         echo $this->name() .
-                          " (parent) forked new child - pid $pid.\n";
+                          " - Forked new child - pid $pid.\n";
 
                     }
 
@@ -120,22 +121,25 @@ class ParallelizingDaemon extends Daemon
                     // 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)) {
@@ -158,7 +162,7 @@ class ParallelizingDaemon extends Daemon
             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);