]> git.mxchange.org Git - hub.git/blobdiff - application/hub/main/producer/cruncher/keys/class_CruncherKeyProducer.php
Introduced experimental apt-proxy sub project (a connector for apt-proxy usage into...
[hub.git] / application / hub / main / producer / cruncher / keys / class_CruncherKeyProducer.php
index 3b14f8e440c79c2b65749355a98aa158616e7f8c..fda0dedd996743981dc1c8c27ebb62fedb4ecc6f 100644 (file)
@@ -4,7 +4,7 @@
  *
  * @author             Roland Haeder <webmaster@ship-simu.org>
  * @version            0.0.0
- * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2011 Hub Developer Team
+ * @copyright  Copyright (c) 2011 - 2012 Cruncher Developer Team
  * @license            GNU GPL 3.0 or any newer version
  * @link               http://www.ship-simu.org
  *
@@ -75,11 +75,11 @@ class CruncherKeyProducer extends BaseKeyProducer implements KeyProducer, Regist
                // Is this cruncher virgin?
                if (!$stateInstance->isCruncherStateVirgin()) {
                        // This cruncher is not virgin, so skip it
-                       $this->debugOutput('ITERATOR: The cruncher is not virgin. stateInstance=' . $stateInstance->__toString() . '.');
+                       self::createDebugInstance(__CLASS__)->debugOutput('PRODUCER: The cruncher is not virgin. stateInstance=' . $stateInstance->__toString() . '');
                        return;
                } elseif (!$this->getIteratorInstance()->valid()) {
-                       // This iterator has finished his assignment
-                       $this->debugOutput('ITERATOR: Finished creating keys.');
+                       // This producer's iterator has finished its assignment
+                       self::createDebugInstance(__CLASS__)->debugOutput('PRODUCER: Finished creating keys. iteratorinstance=' . $this->getIteratorInstance()->__toString() . '');
                        return;
                }
 
@@ -92,12 +92,23 @@ class CruncherKeyProducer extends BaseKeyProducer implements KeyProducer, Regist
                 * and stored to database for later re-usage.
                 */
 
-               // Get current key (which is not the key of the iterator)
-               // This is always an ASCII string.
+               /*
+                * Get current key (which is not the key of the iterator) This is always
+                * an ASCII string.
+                */
                $currentKey = $this->getIteratorInstance()->current();
 
-               // @TODO Do something with it
-               $this->debugOutput('currentKey(b64)="' . base64_encode($currentKey) . '" needs to be processed.');
+               // Add it to the out-going work queue
+               $this->addValueToOutgoingQueue($currentKey);
+
+               // Is the per-work unit limit reached?
+               if ($this->isOutgoingQueueLimitReached('cruncher_per_unit_key_limit')) {
+                       // @TODO Do something with it
+                       self::createDebugInstance(__CLASS__)->debugOutput('currentKey(b64)="' . base64_encode($currentKey) . '" needs to be processed.');
+
+                       // At last re-init the stack
+                       $this->initOutgoingQueue();
+               } // END - if
 
                // Continue with next one
                $this->getIteratorInstance()->next();