Added some pre-checks.
authorRoland Haeder <roland@mxchange.org>
Mon, 29 Jun 2015 03:05:24 +0000 (05:05 +0200)
committerRoland Haeder <roland@mxchange.org>
Mon, 29 Jun 2015 03:05:24 +0000 (05:05 +0200)
Signed-off-by: Roland H├Ąder <roland@mxchange.org>
inc/classes/main/handler/tasks/class_TaskHandler.php

index aa4cb8c..e4183b1 100644 (file)
@@ -214,6 +214,15 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask {
         * @return      void
         */
        public function registerTask ($taskName, Visitable $taskInstance) {
+               // Get interval delay
+               $intervalDelay = $this->getConfigInstance()->getConfigEntry('task_' . $taskName . '_interval_delay');
+               $startupDelay  = $this->getConfigInstance()->getConfigEntry('task_' . $taskName . '_startup_delay');
+
+               // If the task is 'idle_loop', a deplay of zero seconds is fine
+               assert($intervalDelay >= 0);
+               assert(($taskName === 'idle_loop') && ($intervalDelay > 0));
+               assert(($taskName === 'idle_loop') && ($startupDelay > 0));
+
                // Create the entry
                $taskEntry = array(
                        // Identifier for the generateHash() method
@@ -233,9 +242,9 @@ class TaskHandler extends BaseHandler implements Registerable, HandleableTask {
                        // Task instance itself
                        'task_instance'       => $taskInstance,
                        // Startup delay in milliseconds
-                       'task_startup_delay'  => $this->getConfigInstance()->getConfigEntry('task_' . $taskName . '_startup_delay'),
+                       'task_startup_delay'  => $startupDelay,
                        // Interval time (delay) in milliseconds before this task is executed again
-                       'task_interval_delay' => $this->getConfigInstance()->getConfigEntry('task_' . $taskName . '_interval_delay'),
+                       'task_interval_delay' => $intervalDelay,
                        // How often should this task run?
                        'task_max_runs'       => $this->getConfigInstance()->getConfigEntry('task_' . $taskName . '_max_runs'),
                );