]> git.mxchange.org Git - hub.git/blobdiff - application/hub/main/handler/tasks/class_TaskHandler.php
Changed all true/false to TRUE/FALSE respectively as PHP constants are better than...
[hub.git] / application / hub / main / handler / tasks / class_TaskHandler.php
index e9fcc6ec4b90e98a4390ba70f84784e651fa0e33..f1a92b1e6235af6f0cffdf5d2ec8b326fc54821e 100644 (file)
@@ -48,7 +48,7 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask {
                $handlerInstance = new TaskHandler();
 
                // Output debug message
-               $handlerInstance->debugOutput('TASK-HANDLER: Initializing task handler.');
+               self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __LINE__ . ']: Initializing task handler.');
 
                // Init the task list
                $handlerInstance->setListInstance(ObjectFactory::createObjectByConfiguredName('task_list_class'));
@@ -64,7 +64,7 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask {
                $handlerInstance->registerTask('idle_loop', $taskInstance);
 
                // Output debug message
-               $handlerInstance->debugOutput('TASK-HANDLER: Task handler initialized.');
+               self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __LINE__ . ']: Task handler initialized.');
 
                // Return the prepared instance
                return $handlerInstance;
@@ -80,7 +80,7 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask {
         */
        private function executeCurrentTask () {
                // Update no task by default
-               $updateTask = false;
+               $updateTask = FALSE;
 
                // Is the current task valid?
                if (!$this->getListInstance()->getIterator()->valid()) {
@@ -92,22 +92,22 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask {
                $currentTask = $this->getListInstance()->getIterator()->current();
 
                // Is the task not yet started?
-               if ($currentTask['task_started'] === false) {
+               if ($currentTask['task_started'] === FALSE) {
                        // Determine difference between current time and registration
                        $diff = ($this->getMilliTime() - $currentTask['task_registered']) * 1000;
 
                        // Should we start now?
                        if ($diff < $currentTask['task_startup_delay']) {
                                // Skip this silently
-                               return false;
+                               return;
                        } // END - if
 
                        // Launch the task and mark it as updated
-                       $currentTask['task_started'] = true;
-                       $updateTask = true;
+                       $currentTask['task_started'] = TRUE;
+                       $updateTask = TRUE;
 
                        // Debug message
-                       $this->debugOutput('TASK-HANDLER: Task ' . $currentTask['id'] . ' started with startup_delay=' . $currentTask['task_startup_delay'] . 'ms');
+                       self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __LINE__ . ']: Task ' . $currentTask['id'] . ' started with startup_delay=' . $currentTask['task_startup_delay'] . 'ms');
                } // END - if
 
                // Get time difference from interval delay
@@ -116,13 +116,13 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask {
                // Is the interval delay reached?
                if ((($diff < $currentTask['task_interval_delay']) && ($currentTask['task_max_runs'] == 0)) || (($currentTask['task_total_runs'] == $currentTask['task_max_runs']) && ($currentTask['task_max_runs'] > 0))) {
                        // Should we update the task from startup?
-                       if ($updateTask === true) {
+                       if ($updateTask === TRUE) {
                                // Update the task before leaving
                                $this->updateTask($currentTask);
                        } // END - if
 
                        // Skip this silently
-                       return false;
+                       return;
                } // END - if
 
                // Set last activity
@@ -164,13 +164,13 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask {
         */
        private function unregisterTask (array $taskData) {
                // Debug output
-               $this->debugOutput('TASK-HANDLER: Removing task ' . $taskData['id'] . ' from queue - START');
+               self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __LINE__ . ']: Removing task ' . $taskData['id'] . ' from queue - START');
 
                // Remove the entry
                $this->getListInstance()->removeEntry('tasks', $taskData);
 
                // Debug output
-               $this->debugOutput('TASK-HANDLER: Removing task ' . $taskData['id'] . ' from queue - FINISHED');
+               self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __LINE__ . ']: Removing task ' . $taskData['id'] . ' from queue - FINISHED');
         }
 
        /**
@@ -186,11 +186,11 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask {
                        // Identifier for the generateHash() method
                        'id'                  => $taskName,
                        // Whether the task is started
-                       'task_started'        => false,
+                       'task_started'        => FALSE,
                        // Whether the task is paused (not yet implemented)
-                       'task_paused'         => false,
+                       'task_paused'         => FALSE,
                        // Whether the task can be paused (not yet implemented)
-                       'task_pauseable'      => true,
+                       'task_pauseable'      => TRUE,
                        // Timestamp of registration
                        'task_registered'     => $this->getMilliTime(),
                        // Last activity timestamp
@@ -211,7 +211,7 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask {
                $this->getListInstance()->addEntry('tasks', $taskEntry);
 
                // Debug message
-               $this->debugOutput('TASK-HANDLER: Task registered: taskName=' . $taskName .
+               self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __LINE__ . ']: Task registered: taskName=' . $taskName .
                        ' (taskInstance=' . $taskInstance->__toString() . ')' .
                        ', startupDelay=' . $taskEntry['task_startup_delay'] . 'ms' .
                        ', intervalDelay=' . $taskEntry['task_interval_delay'] . 'ms' .
@@ -265,7 +265,7 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask {
                $this->getListInstance()->getIterator()->rewind();
 
                // Debug message
-               $this->debugOutput('TASK-HANDLER: Shutting down all ' . $this->getListInstance()->count() . ' tasks...');
+               self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __LINE__ . ']: Shutting down all ' . $this->getListInstance()->count() . ' tasks...');
 
                // Remember all tasks that has been shutdown for removal
                $tasks = array();
@@ -279,20 +279,20 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask {
                        $currentTask = $this->getListInstance()->getIterator()->current();
 
                        // Output debug message
-                       $this->debugOutput('TASK-HANDLER: Shutting down task ' . $currentTask['id'] . ' (taskInstance=' . $currentTask['task_instance']->__toString() . ') ...');
+                       self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __LINE__ . ']: Shutting down task ' . $currentTask['id'] . ' (taskInstance=' . $currentTask['task_instance']->__toString() . ') ...');
 
                        // Shutdown the task
                        $currentTask['task_instance']->accept($this->getVisitorInstance());
 
                        // Remember this task
-                       $tasks[] = $currentTask;
+                       array_push($tasks, $currentTask);
 
                        // Advance to next one
                        $this->getListInstance()->getIterator()->next();
                } // END - while
 
                // Debug message
-               $this->debugOutput('TASK-HANDLER: Shutdown of all tasks completed.');
+               self::createDebugInstance(__CLASS__)->debugOutput('TASK-HANDLER[' . __LINE__ . ']: Shutdown of all tasks completed.');
 
                // Remove all tasks
                foreach ($tasks as $entry) {