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