From: Roland Häder Date: Sun, 13 Mar 2011 12:09:34 +0000 (+0000) Subject: Some methods moved around (the code is now a some-what template-method-pattern X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=6be42df1d5150b0dfa51cc65e97ec0624bc4c39b;p=hub.git Some methods moved around (the code is now a some-what template-method-pattern --- diff --git a/.gitignore b/.gitignore index ed462c7fc..9fe36b979 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ /.settings db/node_data/*.serialized docs/warn.log +/nbproject diff --git a/application/hub/main/cruncher/class_BaseHubCruncher.php b/application/hub/main/cruncher/class_BaseHubCruncher.php index 54c5c3dec..8a353d010 100644 --- a/application/hub/main/cruncher/class_BaseHubCruncher.php +++ b/application/hub/main/cruncher/class_BaseHubCruncher.php @@ -101,7 +101,7 @@ class BaseHubCruncher extends BaseHubSystem implements Updateable { } /** - * Initializes all buffer queues (mostly in/out), this method is demanded + * Initializes all buffer queues (mostly in/out). This method is demanded * by the CruncherHelper interface. * * @return void @@ -121,6 +121,29 @@ class BaseHubCruncher extends BaseHubSystem implements Updateable { $this->debugOutput('CRUNCHER: All buffers are now initialized.'); } + /** + * This method determines if the in-buffer is going to depleted and if so, + * it fetches more WUs from the network. If no WU can be fetched from the + * network and if enabled, a random test WU is being generated. + * + * This method is demanded from the CruncherHelper interface. + * + * @return void + */ + public function doFetchWorkUnits () { + // Simply check if we have enough WUs left in the in-buffer queue (a FIFO) + if (!$this->isInBufferQueueFilled()) { + // The in-buffer queue needs filling, so head out and get some work + $this->fillInBufferQueueWithWorkUnits(); + + // Is the buffer still not filled and are test-packages allowed? + if ((!$this->isInBufferQueueFilled()) && ($this->getConfigInstance()->getConfigEntry('cruncher_allow_test_units') == 'Y')) { + // Then fill the in-buffer with (one) test-unit(s) + $this->fillInBufferQueueWithTestUnits(); + } // END - if + } // END - if + } + /** * Updates a given field with new value * diff --git a/application/hub/main/cruncher/mcrypt/class_HubMcryptCruncher.php b/application/hub/main/cruncher/mcrypt/class_HubMcryptCruncher.php index c31309971..5d31bf53b 100644 --- a/application/hub/main/cruncher/mcrypt/class_HubMcryptCruncher.php +++ b/application/hub/main/cruncher/mcrypt/class_HubMcryptCruncher.php @@ -53,36 +53,40 @@ class HubMcryptCruncher extends BaseHubCruncher implements CruncherHelper, Regis } /** - * Method to "bootstrap" the cruncher. This step does also apply provided - * command-line arguments stored in the request instance. No buffer queue - * will be initialized here, we do only "general" things here. + * This method fills the in-buffer with (a) test unit(s) which are mainly + * used for development of the crunching part. They must be enabled in + * configuration, or else your cruncher runs out of WUs and waits for more + * to show up. + * + * In this method we already know that the in-buffer is going depleted so + * we don't need to double-check it here. * * @return void - * @todo Implement this method */ - public function doBootstrapping () { + protected function fillInBufferQueueWithTestUnits () { $this->partialStub('Please implement this method.'); } /** - * This method determines if the in-buffer is going to depleted and if so, - * it fetches more WUs from the network. If no WU can be fetched from the - * network and if enabled, a random test WU is being generated. + * This method fills the in-buffer with (real) WUs which will be crunched + * and the result be sent back to the key producer instance. * * @return void */ - public function doFetchWorkUnits () { - // Simply check if we have enough WUs left in the in-buffer queue (a FIFO) - if (!$this->isInBufferQueueFilled()) { - // The in-buffer queue needs filling, so head out and get some work - $this->fillInBufferQueueWithWorkUnits(); + protected function fillInBufferQueueWithWorkUnits () { + $this->partialStub('Please implement this method.'); + } - // Is the buffer still not filled and are test-packages allowed? - if ((!$this->isInBufferQueueFilled()) && ($this->getConfigInstance()->getConfigEntry('cruncher_allow_test_units') == 'Y')) { - // Then fill the in-buffer with (one) test-unit(s) - $this->fillInBufferQueueWithTestUnits(); - } // END - if - } // END - if + /** + * Method to "bootstrap" the cruncher. This step does also apply provided + * command-line arguments stored in the request instance. No buffer queue + * will be initialized here, we only do "general" things here. + * + * @return void + * @todo Implement this method + */ + public function doBootstrapping () { + $this->partialStub('Please implement this method.'); } /**