1
0
Fork 0
mirror of https://github.com/Yetangitu/ampache synced 2025-10-06 03:49:56 +02:00

Move from React 0.4.0 to 0.3.4 for PHP 5.3 compatibility reasons

This commit is contained in:
Afterster 2014-04-13 08:58:34 +02:00
parent d3f01a3bc7
commit 7f82bea13e
50 changed files with 608 additions and 1937 deletions

View file

@ -4,9 +4,12 @@ namespace React\EventLoop\Timer;
use SplObjectStorage;
use SplPriorityQueue;
use InvalidArgumentException;
class Timers
{
const MIN_RESOLUTION = 0.001;
private $time;
private $timers;
private $scheduler;
@ -30,6 +33,11 @@ class Timers
public function add(TimerInterface $timer)
{
$interval = $timer->getInterval();
if ($interval < self::MIN_RESOLUTION) {
throw new InvalidArgumentException('Timer events do not support sub-millisecond timeouts.');
}
$scheduledAt = $interval + $this->getTime();
$this->timers->attach($timer, $scheduledAt);
@ -48,17 +56,13 @@ class Timers
public function getFirst()
{
while ($this->scheduler->count()) {
$timer = $this->scheduler->top();
if ($this->timers->contains($timer)) {
return $this->timers[$timer];
}
$this->scheduler->extract();
if ($this->scheduler->isEmpty()) {
return null;
}
return null;
$scheduledAt = $this->timers[$this->scheduler->top()];
return $scheduledAt;
}
public function isEmpty()