Some updates:
[core.git] / framework / main / classes / tasks / idle / class_IdleLoopTask.php
1 <?php
2 // Own namespace
3 namespace Org\Mxchange\CoreFramework\Task\IdleLoop;
4
5 // Import Framework stuff
6 use Org\Mxchange\CoreFramework\Task\BaseTask;
7 use Org\Mxchange\CoreFramework\Task\Taskable;
8 use Org\Mxchange\CoreFramework\Visitor\Visitable;
9 use Org\Mxchange\CoreFramework\Visitor\Visitor;
10
11 /**
12  * A IdleLoop task
13  *
14  * @author              Roland Haeder <webmaster@shipsimu.org>
15  * @version             0.0.0
16 <<<<<<< HEAD:framework/main/classes/tasks/idle/class_IdleLoopTask.php
17  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
18 =======
19  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team
20 >>>>>>> Some updates::inc/main/classes/tasks/idle/class_IdleLoopTask.php
21  * @license             GNU GPL 3.0 or any newer version
22  * @link                http://www.shipsimu.org
23  *
24  * This program is free software: you can redistribute it and/or modify
25  * it under the terms of the GNU General Public License as published by
26  * the Free Software Foundation, either version 3 of the License, or
27  * (at your option) any later version.
28  *
29  * This program is distributed in the hope that it will be useful,
30  * but WITHOUT ANY WARRANTY; without even the implied warranty of
31  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
32  * GNU General Public License for more details.
33  *
34  * You should have received a copy of the GNU General Public License
35  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
36  */
37 class IdleLoopTask extends BaseTask implements Taskable, Visitable {
38         /**
39          * Idle loop time
40          */
41         private $idleTime = 0;
42
43         /**
44          * Protected constructor
45          *
46          * @return      void
47          */
48         protected function __construct () {
49                 // Call parent constructor
50                 parent::__construct(__CLASS__);
51
52                 // Init idle loop time from config ("cache" it here)
53                 $this->idleTime = $this->getConfigInstance()->getConfigEntry('idle_loop_time');
54         }
55
56         /**
57          * Creates an instance of this class
58          *
59          * @return      $taskInstance   An instance of a Taskable/Visitable class
60          */
61         public static final function createIdleLoopTask () {
62                 // Get new instance
63                 $taskInstance = new IdleLoopTask();
64
65                 // Return the prepared instance
66                 return $taskInstance;
67         }
68
69         /**
70          * Accepts the visitor to process the visitor
71          *
72          * @param       $visitorInstance        An instance of a Visitor class
73          * @return      void
74          */
75         public function accept (Visitor $visitorInstance) {
76                 // Visit this task
77                 $visitorInstance->visitTask($this);
78         }
79
80         /**
81          * Executes the task
82          *
83          * @return      void
84          */
85         public function executeTask () {
86                 // Idle here a little
87                 $this->idle($this->idleTime);
88         }
89
90         /**
91          * Shutdown this task, this does nothing here, just supply the method.
92          *
93          * @return      void
94          */
95         public function doShutdown () {
96                 // Debug message
97                 self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('TASK[' . __METHOD__ . ':' . __LINE__ . ']: Shutting down...');
98         }
99
100 }