From: Roland Haeder Date: Mon, 29 Jun 2015 18:11:16 +0000 (+0200) Subject: Now the idle loop time is configurable, please don't set it to low or to high as X-Git-Url: https://git.mxchange.org/?p=core.git;a=commitdiff_plain;h=a7a0ec871ac1987279a2a750ee664abcff17b609 Now the idle loop time is configurable, please don't set it to low or to high as both will hurt your application's performance and CPU usage. Signed-off-by: Roland Häder --- diff --git a/inc/classes/main/tasks/idle/class_IdleLoopTask.php b/inc/classes/main/tasks/idle/class_IdleLoopTask.php index 0dd2de9f..49379f0d 100644 --- a/inc/classes/main/tasks/idle/class_IdleLoopTask.php +++ b/inc/classes/main/tasks/idle/class_IdleLoopTask.php @@ -22,6 +22,11 @@ * along with this program. If not, see . */ 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); } /** diff --git a/inc/config.php b/inc/config.php index 8e0ffc4f..03c1b9a2 100644 --- a/inc/config.php +++ b/inc/config.php @@ -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');