Fixed timer implementation

This commit is contained in:
2017-01-22 23:22:13 +01:00
parent 0e5a25567c
commit b6727bed80
3 changed files with 31 additions and 3 deletions

View File

@ -137,6 +137,7 @@ class Shell
private $userdata;
public function __construct($interval, callable $handler, array $userdata) {
$this->interval = $interval / 1000;
$this->next = microtime(true) + $this->interval;
$this->handler = $handler;
$this->userdata = $userdata;
}
@ -157,9 +158,11 @@ class Shell
*
* @param Timer $timer
*/
public function removeTimer(Timer $timer)
public function removeTimer($timer)
{
$this->timers = array_filter($this->timers, function ($v) use ($timer) {
return ($v !== $timer);
});
}
public function setPrompt($text)