3 * A WorkUnitFetcher task for crunchers which asks the cruncher to fetch work
4 * units or, if enabled in configuration, work on some test units.
6 * @author Roland Haeder <webmaster@shipsimu.org>
8 * @copyright Copyright (c) 2011 - 2014 Cruncher Developer Team
9 * @license GNU GPL 3.0 or any newer version
10 * @link http://www.shipsimu.org
12 * This program is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation, either version 3 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 class CruncherWorkUnitFetcherTask extends BaseTask implements Taskable, Visitable {
27 * Protected constructor
31 protected function __construct () {
32 // Call parent constructor
33 parent::__construct(__CLASS__);
37 * Creates an instance of this class
39 * @return $taskInstance An instance of a Taskable/Visitable class
41 public final static function createCruncherWorkUnitFetcherTask () {
43 $taskInstance = new CruncherWorkUnitFetcherTask();
45 // Return the prepared instance
50 * Accepts the visitor to process the visitor
52 * @param $visitorInstance An instance of a Visitor class
55 public function accept (Visitor $visitorInstance) {
57 $visitorInstance->visitTask($this);
65 public function executeTask () {
67 * Get the cruncher instance and call a method which should check if
68 * the in-buffer is going to depleted. If so, new WUs are fetched from
69 * network or (if enabled in config) a random test WU is being
70 * generated. This test WU is for developing only or, if you like, to
71 * test your cruncher loop.
73 * Please report any bugs you encounter to me.
75 Registry::getRegistry()->getInstance('cruncher')->doFetchWorkUnits();