]> git.mxchange.org Git - core.git/commitdiff
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 0dd2de9f3d169987f4747f6219f39a9048667826..49379f0d98a311d03e5c817bb120a70cd2e20a75 100644 (file)
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 class IdleLoopTask extends BaseTask implements Taskable, Visitable {
  * 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
         *
        /**
         * Protected constructor
         *
@@ -30,6 +35,9 @@ class IdleLoopTask extends BaseTask implements Taskable, Visitable {
        protected function __construct () {
                // Call parent constructor
                parent::__construct(__CLASS__);
        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 () {
         * @return      void
         */
        public function executeTask () {
-               // Idle here a little (2 milliseconds)
-               $this->idle(2);
+               // Idle here a little
+               $this->idle($this->idleLoopTime);
        }
 
        /**
        }
 
        /**
index 8e0ffc4f2eac807d1dc63a1172137170bcd0a94d..03c1b9a225ff00dbd1716b1b012e7c1ec021adff 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: 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');
 
 // CFG: SHUTDOWN-TASK-VISITOR-CLASS
 $cfg->setConfigEntry('shutdown_task_visitor_class', 'ShutdownTaskVisitor');