]> git.mxchange.org Git - hub.git/blob - application/hub/main/tasks/cruncher/class_CruncherWorkUnitFetcherTask.php
Updated 'core'.
[hub.git] / application / hub / main / tasks / cruncher / class_CruncherWorkUnitFetcherTask.php
1 <?php
2 /**
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.
5  *
6  * @author              Roland Haeder <webmaster@shipsimu.org>
7  * @version             0.0.0
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
11  *
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.
16  *
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.
21  *
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/>.
24  */
25 class CruncherWorkUnitFetcherTask extends BaseTask implements Taskable, Visitable {
26         /**
27          * Protected constructor
28          *
29          * @return      void
30          */
31         protected function __construct () {
32                 // Call parent constructor
33                 parent::__construct(__CLASS__);
34         }
35
36         /**
37          * Creates an instance of this class
38          *
39          * @return      $taskInstance   An instance of a Taskable/Visitable class
40          */
41         public final static function createCruncherWorkUnitFetcherTask () {
42                 // Get new instance
43                 $taskInstance = new CruncherWorkUnitFetcherTask();
44
45                 // Return the prepared instance
46                 return $taskInstance;
47         }
48
49         /**
50          * Accepts the visitor to process the visitor
51          *
52          * @param       $visitorInstance        An instance of a Visitor class
53          * @return      void
54          */
55         public function accept (Visitor $visitorInstance) {
56                 // Visit this task
57                 $visitorInstance->visitTask($this);
58         }
59
60         /**
61          * Executes the task
62          *
63          * @return      void
64          */
65         public function executeTask () {
66                 /*
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.
72                  *
73                  * Please report any bugs you encounter to me.
74                  */
75                 Registry::getRegistry()->getInstance('cruncher')->doFetchWorkUnits();
76         }
77
78         /**
79          * Shuts down the task
80          *
81          * @return      void
82          * @todo        0% done
83          */
84         public function doShutdown () {
85                 self::createDebugInstance(__CLASS__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...');
86         }
87 }
88
89 // [EOF]
90 ?>