Exemplo n.º 1
0
 /**
  * Require specific amount of time, but adjust it dynamically to the longest
  * run between calls to the function.
  *
  * First call - use argument value to require_time. Next - use calculated.
  *
  * @param float $time Default required time - only for the first run.
  *                    Every consecutive call to this function will use
  *                    stored time - calculated during runtime
  */
 public function require_time($time = 0.0)
 {
     $now = microtime(true);
     $last_measured = null;
     if (isset($this->timer_last_run)) {
         $last_measured = $now - $this->timer_last_run;
         if ($last_measured > $this->timer_max_time) {
             $this->timer_max_time = $last_measured;
         }
     }
     $this->timer_last_run = $now;
     if (isset($this->timer_max_time)) {
         $time = $this->timer_max_time;
     }
     $this->save_data();
     PatchUtil::require_time($time);
 }