File tree Expand file tree Collapse file tree 5 files changed +41
-5
lines changed
tests/React/Tests/EventLoop Expand file tree Collapse file tree 5 files changed +41
-5
lines changed Original file line number Diff line number Diff line change 11<?php
22
3- require __DIR__ . '/../vendor/autoload.php ' ;
4-
53$ i = 0 ;
64
75// block all the things!
Original file line number Diff line number Diff 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 ;
Original file line number Diff line number Diff 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 ;
Original file line number Diff line number Diff 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 ;
Original file line number Diff line number Diff 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 (
You can’t perform that action at this time.
0 commit comments