]> git.mxchange.org Git - hub.git/commitdiff
Idle loop added, tasks are simple things to do
authorRoland Häder <roland@mxchange.org>
Sat, 15 Aug 2009 19:11:19 +0000 (19:11 +0000)
committerRoland Häder <roland@mxchange.org>
Sat, 15 Aug 2009 19:11:19 +0000 (19:11 +0000)
.gitattributes
application/hub/config.php
application/hub/interfaces/handler/task/class_HandleableTask.php
application/hub/main/filter/task/class_TaskHandlerInitializerFilter.php
application/hub/main/handler/tasks/class_TaskHandler.php
application/hub/main/tasks/.htaccess [new file with mode: 0644]
application/hub/main/tasks/class_ [new file with mode: 0644]
application/hub/main/tasks/class_BaseTask.php [new file with mode: 0644]
application/hub/main/tasks/idle/.htaccess [new file with mode: 0644]
application/hub/main/tasks/idle/class_IdleLoopTask.php [new file with mode: 0644]

index 77998c9f0cf181ae22007a3b79452e27284145d0..82f2b2aafad82e22515640fdc42ef12e5a19e151 100644 (file)
@@ -199,6 +199,11 @@ application/hub/main/states/client/class_BaseClientState.php -text
 application/hub/main/states/generic/.htaccess -text
 application/hub/main/states/hub/.htaccess -text
 application/hub/main/states/hub/class_BaseHubState.php -text
+application/hub/main/tasks/.htaccess -text
+application/hub/main/tasks/class_ -text
+application/hub/main/tasks/class_BaseTask.php -text
+application/hub/main/tasks/idle/.htaccess -text
+application/hub/main/tasks/idle/class_IdleLoopTask.php -text
 application/hub/main/visitor/.htaccess -text
 application/hub/main/visitor/class_ -text
 application/hub/main/visitor/class_BaseVisitor.php -text
index 380a74b26f653698498e3ab6dab83da8f2fd16e9..76bbc6b7881288fe0e2c6b7038f8530a56c88c34 100644 (file)
@@ -186,5 +186,14 @@ $cfg->setConfigEntry('task_query_handler_startup_delay', 3000);
 // CFG: TASK-QUERY-HANDLER-INTERVAL-DELAY
 $cfg->setConfigEntry('task_query_handler_interval_delay', 10);
 
+// CFG: TASK-IDLE-LOOP-STARTUP-DELAY
+$cfg->setConfigEntry('task_idle_loop_startup_delay', 0);
+
+// CFG: TASK-IDLE-LOOP-INTERVAL-DELAY
+$cfg->setConfigEntry('task_idle_loop_interval_delay', 10);
+
+// CFG: IDLE-TASK-CLASS
+$cfg->setConfigEntry('idle_task_class', 'IdleLoopTask');
+
 // [EOF]
 ?>
index 7bcb9df35f8afb0ffb539ebf876807920d8bcc61..f805475ca4cf9e234b48db604314b396e6ff4b35 100644 (file)
@@ -29,6 +29,7 @@ interface HandleableTask extends Handleable {
         * @param       $taskName       A task name to register the task on
         * @param       $taskInstance   The instance we should register as a task
         * @return      void
+        * @throws      TaskAlreadyRegisteredException  If the given task is already registered
         */
        function registerTask ($taskName, Visitable $taskInstance);
 }
index 1da56ef04cca51ebb36023b8fe8cd3e75db83a51..2d2f3adf14fbe1b234e4143366babc663d2e35e6 100644 (file)
@@ -67,6 +67,12 @@ class TaskHandlerInitializerFilter extends BaseFilter implements Filterable {
                // 2.) Query instance
                $handlerInstance->registerTask('query_handler', $nodeInstance->getQueryInstance());
 
+               // Generate idle task
+               $taskInstance = ObjectFactory::createObjectByConfiguredName('idle_task_class');
+
+               // Register it as well
+               $handlerInstance->registerTask('idle_loop', $taskInstance);
+
                // Put the task handler in registry
                Registry::getRegistry()->addInstance('task', $handlerInstance);
        }
index c9b6c204020fb7864fe23c4c20248c6a9cf93ff2..c4e920555b9326a5b78137eb2fe9b83e504a893f 100644 (file)
@@ -55,6 +55,7 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask {
         * @param       $taskName               A task name to register the task on
         * @param       $taskInstance   The instance we should register as a task
         * @return      void
+        * @throws      TaskAlreadyRegisteredException  If the task is already registered
         */
        public function registerTask ($taskName, Visitable $taskInstance) {
                $this->partialStub('taskName=' . $taskName . '/' . $taskInstance->__toString());
diff --git a/application/hub/main/tasks/.htaccess b/application/hub/main/tasks/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/tasks/class_ b/application/hub/main/tasks/class_
new file mode 100644 (file)
index 0000000..8a8e537
--- /dev/null
@@ -0,0 +1,61 @@
+<?php
+/**
+ * A ??? task
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+class ???Task extends BaseTask implements Visitable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @return      $taskInstance           An instance of a Visitable class
+        */
+       public final static function create???Task () {
+               // Get new instance
+               $taskInstance = new ???Task();
+
+               // Return the prepared instance
+               return $taskInstance;
+       }
+
+       /**
+        * Accepts the visitor to rpocess the visit "request"
+        *
+        * @param       $visitorInstance        An instance of a Visitor class
+        * @return      void
+        * @todo        0%
+        */
+       public function accept (Visitor $visitorInstance) {
+               $this->partialStub('Please implement this method. visitor='.$visitorInstance->__toString());
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/tasks/class_BaseTask.php b/application/hub/main/tasks/class_BaseTask.php
new file mode 100644 (file)
index 0000000..5334b72
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+/**
+ * A general Task
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+class BaseTask extends BaseHubSystem {
+       /**
+        * Protected constructor
+        *
+        * @param       $className      Name of the class
+        * @return      void
+        */
+       protected function __construct ($className) {
+               // Call parent constructor
+               parent::__construct($className);
+       }
+}
+
+// [EOF]
+?>
diff --git a/application/hub/main/tasks/idle/.htaccess b/application/hub/main/tasks/idle/.htaccess
new file mode 100644 (file)
index 0000000..3a42882
--- /dev/null
@@ -0,0 +1 @@
+Deny from all
diff --git a/application/hub/main/tasks/idle/class_IdleLoopTask.php b/application/hub/main/tasks/idle/class_IdleLoopTask.php
new file mode 100644 (file)
index 0000000..29da9db
--- /dev/null
@@ -0,0 +1,61 @@
+<?php
+/**
+ * A IdleLoop task
+ *
+ * @author             Roland Haeder <webmaster@ship-simu.org>
+ * @version            0.0.0
+ * @copyright  Copyright (c) 2007, 2008 Roland Haeder, 2009 Hub Developer Team
+ * @license            GNU GPL 3.0 or any newer version
+ * @link               http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+class IdleLoopTask extends BaseTask implements Visitable {
+       /**
+        * Protected constructor
+        *
+        * @return      void
+        */
+       protected function __construct () {
+               // Call parent constructor
+               parent::__construct(__CLASS__);
+       }
+
+       /**
+        * Creates an instance of this class
+        *
+        * @return      $taskInstance           An instance of a Visitable class
+        */
+       public final static function createIdleLoopTask () {
+               // Get new instance
+               $taskInstance = new IdleLoopTask();
+
+               // Return the prepared instance
+               return $taskInstance;
+       }
+
+       /**
+        * Accepts the visitor to rpocess the visit "request"
+        *
+        * @param       $visitorInstance        An instance of a Visitor class
+        * @return      void
+        * @todo        0%
+        */
+       public function accept (Visitor $visitorInstance) {
+               $this->partialStub('Please implement this method. visitor='.$visitorInstance->__toString());
+       }
+}
+
+// [EOF]
+?>