From cbab35f957b3a05b44a84812ff216428f5e56765 Mon Sep 17 00:00:00 2001 From: Andrew Minerd Date: Fri, 20 May 2016 10:26:42 -0500 Subject: [PATCH 1/3] always use a fresh time when scheduling a timer; fixes #42 --- src/Timer/Timers.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Timer/Timers.php b/src/Timer/Timers.php index c183a637..bebe5520 100644 --- a/src/Timer/Timers.php +++ b/src/Timer/Timers.php @@ -30,7 +30,7 @@ public function getTime() public function add(TimerInterface $timer) { $interval = $timer->getInterval(); - $scheduledAt = $interval + $this->getTime(); + $scheduledAt = $interval + microtime(true); $this->timers->attach($timer, $scheduledAt); $this->scheduler->insert($timer, -$scheduledAt); From 3b797b9e6991193df0b9c6cb8b38e00c9bc155c4 Mon Sep 17 00:00:00 2001 From: Andrew Minerd Date: Tue, 31 May 2016 17:13:40 -0500 Subject: [PATCH 2/3] add test for #42 (timer added after blocking event handler) --- tests/Timer/TimersTest.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 tests/Timer/TimersTest.php diff --git a/tests/Timer/TimersTest.php b/tests/Timer/TimersTest.php new file mode 100644 index 00000000..ef218fa5 --- /dev/null +++ b/tests/Timer/TimersTest.php @@ -0,0 +1,26 @@ +getMockBuilder('React\EventLoop\LoopInterface') + ->getMock(); + + $timers = new Timers(); + $timers->tick(); + + // simulate a bunch of processing on stream events, + // part of which schedules a future timer... + sleep(1); + $timers->add(new Timer($loop, 0.5, function() { + $this->fail("Timer shouldn't be called"); + })); + + $timers->tick(); + } +} From ebed326e375cf3e28c1abbbe5ede67b172af200c Mon Sep 17 00:00:00 2001 From: Andrew Minerd Date: Sun, 14 Aug 2016 15:28:08 -0500 Subject: [PATCH 3/3] fix formatting per psr-2 --- tests/Timer/TimersTest.php | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/tests/Timer/TimersTest.php b/tests/Timer/TimersTest.php index ef218fa5..0ca87e16 100644 --- a/tests/Timer/TimersTest.php +++ b/tests/Timer/TimersTest.php @@ -6,21 +6,24 @@ use React\EventLoop\Timer\Timer; use React\EventLoop\Timer\Timers; -class TimersTest extends TestCase { - public function testBlockedTimer() { - $loop = $this->getMockBuilder('React\EventLoop\LoopInterface') - ->getMock(); - - $timers = new Timers(); - $timers->tick(); - - // simulate a bunch of processing on stream events, - // part of which schedules a future timer... - sleep(1); - $timers->add(new Timer($loop, 0.5, function() { - $this->fail("Timer shouldn't be called"); - })); +class TimersTest extends TestCase +{ + public function testBlockedTimer() + { + $loop = $this + ->getMockBuilder('React\EventLoop\LoopInterface') + ->getMock(); + + $timers = new Timers(); + $timers->tick(); + + // simulate a bunch of processing on stream events, + // part of which schedules a future timer... + sleep(1); + $timers->add(new Timer($loop, 0.5, function () { + $this->fail("Timer shouldn't be called"); + })); - $timers->tick(); - } + $timers->tick(); + } } 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