]> git.mxchange.org Git - hub.git/commitdiff
Removed some dublicate instances to avoid confusion
authorRoland Häder <roland@mxchange.org>
Sun, 21 Mar 2010 00:28:56 +0000 (00:28 +0000)
committerRoland Häder <roland@mxchange.org>
Sun, 21 Mar 2010 00:28:56 +0000 (00:28 +0000)
application/hub/interfaces/connectors/class_Connectable.php
application/hub/main/connectors/query/local/class_LocalQueryConnector.php
application/hub/main/handler/tasks/class_TaskHandler.php
application/hub/main/visitor/tasks/class_ActiveTaskVisitor.php

index e4270e03621122a806a3c5df183b496c33b7bf29..bd6e7c4a13a40b85de5037ded81b81230ed64e3c 100644 (file)
  */
 interface Connectable extends FrameworkInterface {
        /**
-        * Processes all pending queries. This method should be called by the
+        * Handles all pending queries. This method should be called by the
         * ActiveTaskVisitor class and should use an iterator on all pending
         * queries.
         *
         * @return      void
         */
-       function processAllPendingQueries ();
+       function handlePendingQueries ();
 }
 
 // [EOF]
index 2d35cae8a60b223dad1ed4b025685955e4e773be..88dd5c3f221a7af819c306f1a50a4780c314248d 100644 (file)
@@ -85,16 +85,27 @@ class LocalQueryConnector extends BaseQueryConnector implements Connectable, Vis
        }
 
        /**
-        * Processes all pending queries. This method should be called by the
+        * Handles all pending queries. This method should be called by the
         * ActiveTaskVisitor class and should use an iterator on all pending
         * queries.
         *
         * @return      void
         */
-       public function processAllPendingQueries () {
-               $this->partialStub('Please implement this method.');
+       public function handlePendingQueries () {
+               // Should we rewind?
+               if (!$this->getIteratorInstance()->valid()) {
+                       // Rewind to the beginning for next loop
+                       $this->getIteratorInstance()->rewind();
+               } // END - if
+
+               // Try to execute the task
+               $this->handleCurrentQuery();
+
+               // Go to next entry
+               $this->getIteratorInstance()->next();
        }
 }
 
 // [EOF]
 ?>
+
index 9799fb06dd3f7d72430d7dff668583a1662a5f14..a1ecf3016e48bf24e9a9012bcde467af43666fb1 100644 (file)
@@ -25,16 +25,6 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask {
        // Exception constants
        const EXCEPTION_TASK_IS_INVALID = 0xb00;
 
-       /**
-        * A task list instance
-        */
-       private $listInstance = null;
-
-       /**
-        * Instance for iterator
-        */
-       private $iteratorInstance = null;
-
        /**
         * Visitor instance for all tasks while they are active
         */
@@ -50,10 +40,10 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask {
                parent::__construct(__CLASS__);
 
                // Init the task list
-               $this->listInstance = ObjectFactory::createObjectByConfiguredName('task_list_class');
+               $this->setListInstance(ObjectFactory::createObjectByConfiguredName('task_list_class'));
 
                // Get default instance
-               $this->iteratorInstance = $this->listInstance->getIterator();
+               $this->setIteratorInstance($this->getListInstance()->getIterator());
 
                // Init visitor instance for faster loop
                $this->visitorInstance = ObjectFactory::createObjectByConfiguredName('active_task_visitor_class');
@@ -88,13 +78,13 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask {
                $updateTask = false;
 
                // Is the current task valid?
-               if (!$this->iteratorInstance->valid()) {
+               if (!$this->getIteratorInstance()->valid()) {
                        // Not valid!
                        throw new InvalidTaskException($this, self::EXCEPTION_TASK_IS_INVALID);
                } // END - if
 
                // Get current task
-               $currentTask = $this->iteratorInstance->current();
+               $currentTask = $this->getIteratorInstance()->current();
 
                // Is the task not yet started?
                if ($currentTask['task_started'] === false) {
@@ -152,13 +142,13 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask {
         */
        private function updateTask (array $taskEntry) {
                // Get the key from current iteration
-               $key = $this->iteratorInstance->key();
+               $key = $this->getIteratorInstance()->key();
 
                // Get the hash from key
-               $hash = $this->listInstance->getHash($key);
+               $hash = $this->getListInstance()->getHash($key);
 
                // Update the entry
-               $this->listInstance->updateCurrentEntryByHash($hash, $taskEntry);
+               $this->getListInstance()->updateCurrentEntryByHash($hash, $taskEntry);
        }
 
        /**
@@ -169,7 +159,7 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask {
         */
         private function unregisterTask ($taskName) {
                // Remove the entry
-               $this->listInstance->removeEntry('tasks', $taskName);
+               $this->getListInstance()->removeEntry('tasks', $taskName);
         }
 
        /**
@@ -207,7 +197,7 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask {
                );
 
                // Add the entry
-               $this->listInstance->addEntry('tasks', $taskEntry);
+               $this->getListInstance()->addEntry('tasks', $taskEntry);
 
                // Debug message
                $this->debugOutput('TASK-HANDLER: Task ' . $taskName .
@@ -225,7 +215,7 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask {
         */
        public function hasTasksLeft () {
                // Do we have tasks there?
-               $tasksLeft = (($this->listInstance instanceof Listable) && ($this->listInstance->count() > 0));
+               $tasksLeft = (($this->getListInstance() instanceof Listable) && ($this->getListInstance()->count() > 0));
 
                // Return result
                return $tasksLeft;
@@ -241,16 +231,16 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask {
         */
        public function handleTasks () {
                // Should we rewind?
-               if (!$this->iteratorInstance->valid()) {
+               if (!$this->getIteratorInstance()->valid()) {
                        // Rewind to the beginning for next loop
-                       $this->iteratorInstance->rewind();
+                       $this->getIteratorInstance()->rewind();
                } // END - if
 
                // Try to execute the task
                $this->executeCurrentTask();
 
                // Go to next entry
-               $this->iteratorInstance->next();
+               $this->getIteratorInstance()->next();
        }
 
        /**
@@ -261,21 +251,21 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask {
         */
        public function doShutdown () {
                // Should we rewind?
-               if (!$this->iteratorInstance->valid()) {
+               if (!$this->getIteratorInstance()->valid()) {
                        // Rewind to the beginning for next loop
-                       $this->iteratorInstance->rewind();
+                       $this->getIteratorInstance()->rewind();
                } // END - if
 
                // Debug message
-               $this->debugOutput('TASK-HANDLER: Shutting down all ' . $this->listInstance->count() . ' tasks...');
+               $this->debugOutput('TASK-HANDLER: Shutting down all ' . $this->getListInstance()->count() . ' tasks...');
 
                // Remember all tasks that has been shutdown for removal
                $tasks = array();
 
                // Shutdown all tasks in once go
-               while ($this->iteratorInstance->valid()) {
+               while ($this->getIteratorInstance()->valid()) {
                        // Get current entry
-                       $current = $this->iteratorInstance->current();
+                       $current = $this->getIteratorInstance()->current();
 
                        // Output debug message
                        $this->debugOutput('TASK-HANDLER: Shutting down task ' . $current['id'] . ' (taskInstance=' . $current['task_instance']->__toString() . ') ...');
@@ -287,7 +277,7 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask {
                        $tasks[] = $current;
 
                        // Advance to next one
-                       $this->iteratorInstance->next();
+                       $this->getIteratorInstance()->next();
                } // END - while
 
 
index e352a9a6eb2f608a95798ff0ee6e3fc1e38ee3fc..81717d21af87ac20ab6fb91077fe991619f2b5e3 100644 (file)
@@ -67,7 +67,7 @@ class ActiveTaskVisitor extends BaseVisitor implements TaskVisitor, QueryConnect
         */
        public function visitQueryConnector (Connectable $connectorInstance) {
                // Process all pending queries
-               $connectorInstance->processAllPendingQueries();
+               $connectorInstance->handlePendingQueries();
        }
 
        /**
@@ -77,9 +77,11 @@ class ActiveTaskVisitor extends BaseVisitor implements TaskVisitor, QueryConnect
         * @return      void
         */
        public function visitPool (Poolable $poolInstance) {
-               // We don't need to visit a pool as an active task because a pool can
-               // never become a task. Instead e.g. by a listener pool we should visit
-               // all listeners one by one
+               /**
+                * We don't need to visit a pool as an active task because a pool can
+                * never become a task. Instead e.g. by a listener pool we should visit
+                * all listeners one by one
+                */
        }
 
        /**