Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Rename PeclEvLoop private members in StreamSelectLoop way.
  • Loading branch information
ivkalita committed Apr 8, 2017
commit 4c70da0e8a21c17257eb5a0bc8903adc4cbbd69c
38 changes: 19 additions & 19 deletions src/PeclEvLoop.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ class PeclEvLoop implements LoopInterface
{
private $loop;
private $futureTickQueue;
private $timerEvents;
private $readEvents = [];
private $writeEvents = [];
private $timers;
private $readStreams = [];
private $writeStreams = [];
private $running;

public function __construct()
{
$this->loop = new EvLoop();
$this->futureTickQueue = new FutureTickQueue($this);
$this->timerEvents = new SplObjectStorage();
$this->timers = new SplObjectStorage();
}

/**
Expand All @@ -39,7 +39,7 @@ public function addReadStream($stream, callable $listener)

$event = $this->loop->io($stream, Ev::READ, $callback);

$this->readEvents[(int) $stream] = $event;
$this->readStreams[(int) $stream] = $event;
}

/**
Expand All @@ -53,7 +53,7 @@ public function addWriteStream($stream, callable $listener)

$event = $this->loop->io($stream, Ev::WRITE, $callback);

$this->writeEvents[(int) $stream] = $event;
$this->writeStreams[(int) $stream] = $event;
}

/**
Expand All @@ -63,9 +63,9 @@ public function removeReadStream($stream)
{
$key = (int) $stream;

if (isset($this->readEvents[$key])) {
$this->readEvents[$key]->stop();
unset($this->readEvents[$key]);
if (isset($this->readStreams[$key])) {
$this->readStreams[$key]->stop();
unset($this->readStreams[$key]);
}
}

Expand All @@ -76,9 +76,9 @@ public function removeWriteStream($stream)
{
$key = (int) $stream;

if (isset($this->writeEvents[$key])) {
$this->writeEvents[$key]->stop();
unset($this->writeEvents[$key]);
if (isset($this->writeStreams[$key])) {
$this->writeStreams[$key]->stop();
unset($this->writeStreams[$key]);
}
}

Expand Down Expand Up @@ -107,7 +107,7 @@ public function addTimer($interval, callable $callback)
};

$event = $this->loop->timer($timer->getInterval(), 0.0, $callback);
$this->timerEvents->attach($timer, $event);
$this->timers->attach($timer, $event);

return $timer;
}
Expand All @@ -125,7 +125,7 @@ public function addPeriodicTimer($interval, callable $callback)

//reschedule callback should be NULL to utilize $offset and $interval params
$event = $this->loop->periodic($interval, $interval, NULL, $callback);
$this->timerEvents->attach($timer, $event);
$this->timers->attach($timer, $event);

return $timer;
}
Expand All @@ -135,10 +135,10 @@ public function addPeriodicTimer($interval, callable $callback)
*/
public function cancelTimer(TimerInterface $timer)
{
if (isset($this->timerEvents[$timer])) {
$event = $this->timerEvents[$timer];
if (isset($this->timers[$timer])) {
$event = $this->timers[$timer];
$event->stop();
$this->timerEvents->detach($timer);
$this->timers->detach($timer);
}
}

Expand All @@ -147,7 +147,7 @@ public function cancelTimer(TimerInterface $timer)
*/
public function isTimerActive(TimerInterface $timer)
{
return $this->timerEvents->contains($timer);
return $this->timers->contains($timer);
}

/**
Expand Down Expand Up @@ -181,7 +181,7 @@ public function run()
$flags = Ev::RUN_ONCE;
if (!$this->running || !$this->futureTickQueue->isEmpty()) {
$flags |= Ev::RUN_NOWAIT;
} elseif (!$this->readEvents && !$this->writeEvents && !$this->timerEvents->count()) {
} elseif (!$this->readStreams && !$this->writeStreams && !$this->timers->count()) {
break;
}

Expand Down