File tree Expand file tree Collapse file tree 4 files changed +41
-3
lines changed
tests/React/Tests/EventLoop Expand file tree Collapse file tree 4 files changed +41
-3
lines changed Original file line number Diff line number Diff line change @@ -194,7 +194,7 @@ public function run()
194
194
$ this ->futureTickQueue ->tick ();
195
195
196
196
$ flags = EventBase::LOOP_ONCE ;
197
- if (!$ this ->running || !$ this ->futureTickQueue ->isEmpty ()) {
197
+ if (!$ this ->running || !$ this ->nextTickQueue -> isEmpty () || ! $ this -> futureTickQueue ->isEmpty ()) {
198
198
$ flags |= EventBase::LOOP_NONBLOCK ;
199
199
} elseif (!$ this ->streamEvents && !$ this ->timerEvents ->count ()) {
200
200
break ;
Original file line number Diff line number Diff line change @@ -198,7 +198,7 @@ public function run()
198
198
$ this ->futureTickQueue ->tick ();
199
199
200
200
$ flags = EventLoop::RUN_ONCE ;
201
- if (!$ this ->running || !$ this ->futureTickQueue ->isEmpty ()) {
201
+ if (!$ this ->running || !$ this ->nextTickQueue -> isEmpty () || ! $ this -> futureTickQueue ->isEmpty ()) {
202
202
$ flags |= EventLoop::RUN_NOWAIT ;
203
203
} elseif (!$ this ->readEvents && !$ this ->writeEvents && !$ this ->timerEvents ->count ()) {
204
204
break ;
Original file line number Diff line number Diff line change @@ -202,7 +202,7 @@ public function run()
202
202
$ this ->futureTickQueue ->tick ();
203
203
204
204
$ flags = EVLOOP_ONCE ;
205
- if (!$ this ->running || !$ this ->futureTickQueue ->isEmpty ()) {
205
+ if (!$ this ->running || !$ this ->nextTickQueue -> isEmpty () || ! $ this -> futureTickQueue ->isEmpty ()) {
206
206
$ flags |= EVLOOP_NONBLOCK ;
207
207
} elseif (!$ this ->streamEvents && !$ this ->timerEvents ->count ()) {
208
208
break ;
Original file line number Diff line number Diff line change @@ -320,6 +320,25 @@ function () {
320
320
$ this ->loop ->run ();
321
321
}
322
322
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
+
323
342
public function testNextTickEventGeneratedByTimer ()
324
343
{
325
344
$ this ->loop ->addTimer (
@@ -427,6 +446,25 @@ function () {
427
446
$ this ->loop ->run ();
428
447
}
429
448
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
+
430
468
public function testFutureTickEventGeneratedByTimer ()
431
469
{
432
470
$ this ->loop ->addTimer (
You can’t perform that action at this time.
0 commit comments