8000 [EventLoop] Apply changes after code review. · Undefined-Variables/event-loop@cf697fe · GitHub
[go: up one dir, main page]

Skip to content

Commit cf697fe

Browse files
committed
[EventLoop] Apply changes after code review.
Also removed a couple of unneeded use directives.
1 parent 7e7cc49 commit cf697fe

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

LibEvLoop.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace React\EventLoop;
44

55
use SplObjectStorage;
6-
use libev\TimerEvent as LibEvTimer;
76
use React\EventLoop\Timer\Timer;
87
use React\EventLoop\Timer\TimerInterface;
98

@@ -127,7 +126,7 @@ private function setupTimer(TimerInterface $timer)
127126
$libevTimer->setCallback(function () use ($timer) {
128127
call_user_func($timer->getCallback(), $timer);
129128

130-
if ($timer->isPeriodic() === false) {
129+
if (!$timer->isPeriodic()) {
131130
$timer->cancel();
132131
}
133132
});

LibEventLoop.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,15 +159,16 @@ protected function addTimerInternal($interval, $callback, $periodic = false)
159159
}
160160

161161
$timer = new Timer($this, $interval, $callback, $periodic);
162+
$resource = event_new();
162163

163164
$timers = $this->timers;
164-
$timers->attach($timer, $resource = event_new());
165+
$timers->attach($timer, $resource);
165166

166167
$callback = function () use ($timers, $timer, &$callback) {
167-
if (isset($timers[$timer]) === true) {
168+
if (isset($timers[$timer])) {
168169
call_user_func($timer->getCallback(), $timer);
169170

170-
if ($timer->isPeriodic() === true && isset($timers[$timer]) === true) {
171+
if ($timer->isPeriodic() && isset($timers[$timer])) {
171172
event_add($timers[$timer], $timer->getInterval() * 1000000);
172173
} else {
173174
$timer->cancel();

Timer/Timers.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use SplObjectStorage;
66
use SplPriorityQueue;
77
use InvalidArgumentException;
8-
use React\EventLoop\LoopInterface;
98

109
class Timers
1110
{
@@ -77,10 +76,10 @@ public function tick()
7776
$timers = $this->timers;
7877
$scheduler = $this->scheduler;
7978

80-
while ($scheduler->isEmpty() === false) {
79+
while (!$scheduler->isEmpty()) {
8180
$timer = $scheduler->top();
8281

83-
if (isset($timers[$timer]) === false) {
82+
if (!isset($timers[$timer])) {
8483
$scheduler->extract();
8584
$timers->detach($timer);
8685

0 commit comments

Comments
 (0)
0