Now the idle loop time is configurable, please don't set it to low or to high as
authorRoland Haeder <roland@mxchange.org>
Mon, 29 Jun 2015 18:11:16 +0000 (20:11 +0200)
committerRoland Haeder <roland@mxchange.org>
Mon, 29 Jun 2015 18:11:16 +0000 (20:11 +0200)
both will hurt your application's performance and CPU usage.

Signed-off-by: Roland H├Ąder <roland@mxchange.org>
inc/classes/main/tasks/idle/class_IdleLoopTask.php
inc/config.php

index 0dd2de9..49379f0 100644 (file)
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 class IdleLoopTask extends BaseTask implements Taskable, Visitable {
+       /**
+        * Idle loop time
+        */
+       private $idleTime = 0;
+
        /**
         * Protected constructor
         *
@@ -30,6 +35,9 @@ class IdleLoopTask extends BaseTask implements Taskable, Visitable {
        protected function __construct () {
                // Call parent constructor
                parent::__construct(__CLASS__);
+
+               // Init idle loop time from config ("cache" it here)
+               $this->idleLoop = $this->getConfigInstance()->getConfigEntry('idle_loop_time');
        }
 
        /**
@@ -62,8 +70,8 @@ class IdleLoopTask extends BaseTask implements Taskable, Visitable {
         * @return      void
         */
        public function executeTask () {
-               // Idle here a little (2 milliseconds)
-               $this->idle(2);
+               // Idle here a little
+               $this->idle($this->idleLoopTime);
        }
 
        /**
index 8e0ffc4..03c1b9a 100644 (file)
@@ -431,6 +431,9 @@ $cfg->setConfigEntry('task_idle_loop_interval_delay', 0);
 // CFG: TASK-IDLE-LOOP-MAX-RUNS
 $cfg->setConfigEntry('task_idle_loop_max_runs', 0);
 
+// CFG: IDLE-LOOP-TIME (5 milli seconds)
+$cfg->setConfigEntry('idle_loop_time', 5);
+
 // CFG: SHUTDOWN-TASK-VISITOR-CLASS
 $cfg->setConfigEntry('shutdown_task_visitor_class', 'ShutdownTaskVisitor');