Skip to content

Commit 191a668

Browse files
committed
Added missing check for non-empty next-tick queue.
1 parent c79e744 commit 191a668

File tree

4 files changed

+41
-3
lines changed

4 files changed

+41
-3
lines changed

src/React/EventLoop/ExtEventLoop.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ public function run()
194194
$this->futureTickQueue->tick();
195195

196196
$flags = EventBase::LOOP_ONCE;
197-
if (!$this->running || !$this->futureTickQueue->isEmpty()) {
197+
if (!$this->running || !$this->nextTickQueue->isEmpty() || !$this->futureTickQueue->isEmpty()) {
198198
$flags |= EventBase::LOOP_NONBLOCK;
199199
} elseif (!$this->streamEvents && !$this->timerEvents->count()) {
200200
break;

src/React/EventLoop/LibEvLoop.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ public function run()
198198
$this->futureTickQueue->tick();
199199

200200
$flags = EventLoop::RUN_ONCE;
201-
if (!$this->running || !$this->futureTickQueue->isEmpty()) {
201+
if (!$this->running || !$this->nextTickQueue->isEmpty() || !$this->futureTickQueue->isEmpty()) {
202202
$flags |= EventLoop::RUN_NOWAIT;
203203
} elseif (!$this->readEvents && !$this->writeEvents && !$this->timerEvents->count()) {
204204
break;

src/React/EventLoop/LibEventLoop.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ public function run()
202202
$this->futureTickQueue->tick();
203203

204204
$flags = EVLOOP_ONCE;
205-
if (!$this->running || !$this->futureTickQueue->isEmpty()) {
205+
if (!$this->running || !$this->nextTickQueue->isEmpty() || !$this->futureTickQueue->isEmpty()) {
206206
$flags |= EVLOOP_NONBLOCK;
207207
} elseif (!$this->streamEvents && !$this->timerEvents->count()) {
208208
break;

tests/React/Tests/EventLoop/AbstractLoopTest.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,25 @@ function () {
320320
$this->loop->run();
321321
}
322322

323+
public function testNextTickEventGeneratedByFutureTick()
324+
{
325+
$stream = $this->createStream();
326+
327+
$this->loop->futureTick(
328+
function () {
329+
$this->loop->nextTick(
330+
function () {
331+
echo 'next-tick' . PHP_EOL;
332+
}
333+
);
334+
}
335+
);
336+
337+
$this->expectOutputString('next-tick' . PHP_EOL);
338+
339+
$this->loop->run();
340+
}
341+
323342
public function testNextTickEventGeneratedByTimer()
324343
{
325344
$this->loop->addTimer(
@@ -427,6 +446,25 @@ function () {
427446
$this->loop->run();
428447
}
429448

449+
public function testFutureTickEventGeneratedByNextTick()
450+
{
451+
$stream = $this->createStream();
452+
453+
$this->loop->nextTick(
454+
function () {
455+
$this->loop->futureTick(
456+
function () {
457+
echo 'future-tick' . PHP_EOL;
458+
}
459+
);
460+
}
461+
);
462+
463+
$this->expectOutputString('future-tick' . PHP_EOL);
464+
465+
$this->loop->run();
466+
}
467+
430468
public function testFutureTickEventGeneratedByTimer()
431469
{
432470
$this->loop->addTimer(

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy