From 8fa040756c3a62de2e5e160c2a4d63595c0c658e Mon Sep 17 00:00:00 2001 From: Jan Sorgalla Date: Fri, 3 Feb 2017 10:01:27 +0100 Subject: [PATCH 1/2] Drop tick() from LoopInterface --- src/ExtEventLoop.php | 13 ---------- src/LibEvLoop.php | 12 ---------- src/LibEventLoop.php | 12 ---------- src/LoopInterface.php | 5 ---- src/StreamSelectLoop.php | 14 ----------- tests/AbstractLoopTest.php | 40 +++++++++++++++---------------- tests/ExtEventLoopTest.php | 4 ++-- tests/TestCase.php | 11 +++++++++ tests/Timer/AbstractTimerTest.php | 20 ++++++++-------- 9 files changed, 43 insertions(+), 88 deletions(-) diff --git a/src/ExtEventLoop.php b/src/ExtEventLoop.php index 7160c908..593c2c62 100644 --- a/src/ExtEventLoop.php +++ b/src/ExtEventLoop.php @@ -169,19 +169,6 @@ public function futureTick(callable $listener) $this->futureTickQueue->add($listener); } - /** - * {@inheritdoc} - */ - public function tick() - { - $this->nextTickQueue->tick(); - - $this->futureTickQueue->tick(); - - // @-suppression: https://github.com/reactphp/react/pull/234#discussion-diff-7759616R226 - @$this->eventBase->loop(EventBase::LOOP_ONCE | EventBase::LOOP_NONBLOCK); - } - /** * {@inheritdoc} */ diff --git a/src/LibEvLoop.php b/src/LibEvLoop.php index 38e4ec2c..ca3426a9 100644 --- a/src/LibEvLoop.php +++ b/src/LibEvLoop.php @@ -173,18 +173,6 @@ public function futureTick(callable $listener) $this->futureTickQueue->add($listener); } - /** - * {@inheritdoc} - */ - public function tick() - { - $this->nextTickQueue->tick(); - - $this->futureTickQueue->tick(); - - $this->loop->run(EventLoop::RUN_ONCE | EventLoop::RUN_NOWAIT); - } - /** * {@inheritdoc} */ diff --git a/src/LibEventLoop.php b/src/LibEventLoop.php index 99417a12..f6a4aba0 100644 --- a/src/LibEventLoop.php +++ b/src/LibEventLoop.php @@ -177,18 +177,6 @@ public function futureTick(callable $listener) $this->futureTickQueue->add($listener); } - /** - * {@inheritdoc} - */ - public function tick() - { - $this->nextTickQueue->tick(); - - $this->futureTickQueue->tick(); - - event_base_loop($this->eventBase, EVLOOP_ONCE | EVLOOP_NONBLOCK); - } - /** * {@inheritdoc} */ diff --git a/src/LoopInterface.php b/src/LoopInterface.php index d046526c..bb01d720 100644 --- a/src/LoopInterface.php +++ b/src/LoopInterface.php @@ -104,11 +104,6 @@ public function nextTick(callable $listener); */ public function futureTick(callable $listener); - /** - * Perform a single iteration of the event loop. - */ - public function tick(); - /** * Run the event loop until there are no more tasks to perform. */ diff --git a/src/StreamSelectLoop.php b/src/StreamSelectLoop.php index e51a27f8..f0d68e1a 100644 --- a/src/StreamSelectLoop.php +++ b/src/StreamSelectLoop.php @@ -148,20 +148,6 @@ public function futureTick(callable $listener) $this->futureTickQueue->add($listener); } - /** - * {@inheritdoc} - */ - public function tick() - { - $this->nextTickQueue->tick(); - - $this->futureTickQueue->tick(); - - $this->timers->tick(); - - $this->waitForStreamActivity(0); - } - /** * {@inheritdoc} */ diff --git a/tests/AbstractLoopTest.php b/tests/AbstractLoopTest.php index 50b3e432..c45c4d7a 100644 --- a/tests/AbstractLoopTest.php +++ b/tests/AbstractLoopTest.php @@ -38,10 +38,10 @@ public function testAddReadStream() $this->loop->addReadStream($input, $this->expectCallableExactly(2)); $this->writeToStream($input, "foo\n"); - $this->loop->tick(); + $this->tickLoop($this->loop); $this->writeToStream($input, "bar\n"); - $this->loop->tick(); + $this->tickLoop($this->loop); } public function testAddWriteStream() @@ -49,8 +49,8 @@ public function testAddWriteStream() $input = $this->createStream(); $this->loop->addWriteStream($input, $this->expectCallableExactly(2)); - $this->loop->tick(); - $this->loop->tick(); + $this->tickLoop($this->loop); + $this->tickLoop($this->loop); } public function testRemoveReadStreamInstantly() @@ -61,7 +61,7 @@ public function testRemoveReadStreamInstantly() $this->loop->removeReadStream($input); $this->writeToStream($input, "bar\n"); - $this->loop->tick(); + $this->tickLoop($this->loop); } public function testRemoveReadStreamAfterReading() @@ -71,12 +71,12 @@ public function testRemoveReadStreamAfterReading() $this->loop->addReadStream($input, $this->expectCallableOnce()); $this->writeToStream($input, "foo\n"); - $this->loop->tick(); + $this->tickLoop($this->loop); $this->loop->removeReadStream($input); $this->writeToStream($input, "bar\n"); - $this->loop->tick(); + $this->tickLoop($this->loop); } public function testRemoveWriteStreamInstantly() @@ -85,7 +85,7 @@ public function testRemoveWriteStreamInstantly() $this->loop->addWriteStream($input, $this->expectCallableNever()); $this->loop->removeWriteStream($input); - $this->loop->tick(); + $this->tickLoop($this->loop); } public function testRemoveWriteStreamAfterWriting() @@ -93,10 +93,10 @@ public function testRemoveWriteStreamAfterWriting() $input = $this->createStream(); $this->loop->addWriteStream($input, $this->expectCallableOnce()); - $this->loop->tick(); + $this->tickLoop($this->loop); $this->loop->removeWriteStream($input); - $this->loop->tick(); + $this->tickLoop($this->loop); } public function testRemoveStreamInstantly() @@ -108,7 +108,7 @@ public function testRemoveStreamInstantly() $this->loop->removeStream($input); $this->writeToStream($input, "bar\n"); - $this->loop->tick(); + $this->tickLoop($this->loop); } public function testRemoveStreamForReadOnly() @@ -120,7 +120,7 @@ public function testRemoveStreamForReadOnly() $this->loop->removeReadStream($input); $this->writeToStream($input, "foo\n"); - $this->loop->tick(); + $this->tickLoop($this->loop); } public function testRemoveStreamForWriteOnly() @@ -133,7 +133,7 @@ public function testRemoveStreamForWriteOnly() $this->loop->addWriteStream($input, $this->expectCallableNever()); $this->loop->removeWriteStream($input); - $this->loop->tick(); + $this->tickLoop($this->loop); } public function testRemoveStream() @@ -144,12 +144,12 @@ public function testRemoveStream() $this->loop->addWriteStream($input, $this->expectCallableOnce()); $this->writeToStream($input, "bar\n"); - $this->loop->tick(); + $this->tickLoop($this->loop); $this->loop->removeStream($input); $this->writeToStream($input, "bar\n"); - $this->loop->tick(); + $this->tickLoop($this->loop); } public function testRemoveInvalid() @@ -251,7 +251,7 @@ public function testNextTick() $this->assertFalse($called); - $this->loop->tick(); + $this->tickLoop($this->loop); $this->assertTrue($called); } @@ -275,7 +275,7 @@ function () { $this->expectOutputString('next-tick' . PHP_EOL . 'stream' . PHP_EOL); - $this->loop->tick(); + $this->tickLoop($this->loop); } public function testRecursiveNextTick() @@ -301,7 +301,7 @@ function () { $this->expectOutputString('next-tick' . PHP_EOL . 'stream' . PHP_EOL); - $this->loop->tick(); + $this->tickLoop($this->loop); } public function testRunWaitsForNextTickEvents() @@ -375,7 +375,7 @@ public function testFutureTick() $this->assertFalse($called); - $this->loop->tick(); + $this->tickLoop($this->loop); $this->assertTrue($called); } @@ -399,7 +399,7 @@ function () { $this->expectOutputString('future-tick' . PHP_EOL . 'stream' . PHP_EOL); - $this->loop->tick(); + $this->tickLoop($this->loop); } public function testRecursiveFutureTick() diff --git a/tests/ExtEventLoopTest.php b/tests/ExtEventLoopTest.php index 71f798c1..761ff962 100644 --- a/tests/ExtEventLoopTest.php +++ b/tests/ExtEventLoopTest.php @@ -82,9 +82,9 @@ public function testCanUseReadableStreamWithFeatureFds() $this->loop->addReadStream($input, $this->expectCallableExactly(2)); $this->writeToStream($input, "foo\n"); - $this->loop->tick(); + $this->tickLoop($this->loop); $this->writeToStream($input, "bar\n"); - $this->loop->tick(); + $this->tickLoop($this->loop); } } diff --git a/tests/TestCase.php b/tests/TestCase.php index 5114f4e0..0bc26a40 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -2,6 +2,8 @@ namespace React\Tests\EventLoop; +use React\EventLoop\LoopInterface; + class TestCase extends \PHPUnit_Framework_TestCase { protected function expectCallableExactly($amount) @@ -38,4 +40,13 @@ protected function createCallableMock() { return $this->getMockBuilder('React\Tests\EventLoop\CallableStub')->getMock(); } + + protected function tickLoop(LoopInterface $loop) + { + $loop->futureTick(function () use ($loop) { + $loop->stop(); + }); + + $loop->run(); + } } diff --git a/tests/Timer/AbstractTimerTest.php b/tests/Timer/AbstractTimerTest.php index 57689658..e930ad37 100644 --- a/tests/Timer/AbstractTimerTest.php +++ b/tests/Timer/AbstractTimerTest.php @@ -16,7 +16,7 @@ public function testAddTimer() $loop->addTimer(0.001, $this->expectCallableOnce()); usleep(1000); - $loop->tick(); + $this->tickLoop($loop); } public function testAddPeriodicTimer() @@ -25,11 +25,11 @@ public function testAddPeriodicTimer() $loop->addPeriodicTimer(0.001, $this->expectCallableExactly(3)); usleep(1000); - $loop->tick(); + $this->tickLoop($loop); usleep(1000); - $loop->tick(); + $this->tickLoop($loop); usleep(1000); - $loop->tick(); + $this->tickLoop($loop); } public function testAddPeriodicTimerWithCancel() @@ -39,14 +39,14 @@ public function testAddPeriodicTimerWithCancel() $timer = $loop->addPeriodicTimer(0.001, $this->expectCallableExactly(2)); usleep(1000); - $loop->tick(); + $this->tickLoop($loop); usleep(1000); - $loop->tick(); + $this->tickLoop($loop); $timer->cancel(); usleep(1000); - $loop->tick(); + $this->tickLoop($loop); } public function testAddPeriodicTimerCancelsItself() @@ -64,11 +64,11 @@ public function testAddPeriodicTimerCancelsItself() }); usleep(1000); - $loop->tick(); + $this->tickLoop($loop); usleep(1000); - $loop->tick(); + $this->tickLoop($loop); usleep(1000); - $loop->tick(); + $this->tickLoop($loop); $this->assertSame(2, $i); } From 665fde6cb0834624e0d227c9146f0e5d656d2bc3 Mon Sep 17 00:00:00 2001 From: Jan Sorgalla Date: Fri, 3 Feb 2017 11:03:13 +0100 Subject: [PATCH 2/2] Add changelog entry for removing LoopInterface::tick() --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 30787694..79bf001a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 0.5.0 (xxxx-xx-xx) + +* BC break: Remove `LoopInterface::tick()` (@jsor, #72) + ## 0.4.2 (2016-03-07) * Bug fix: No longer error when signals sent to StreamSelectLoop 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