From 110e8f2fef82423d03f3e04fdece376beb932178 Mon Sep 17 00:00:00 2001 From: Daniel Lowrey Date: Sun, 17 Nov 2013 17:58:41 -0500 Subject: [PATCH] Removed unnecessary intermediary garbage storage --- src/Alert/NativeReactor.php | 7 ------- test/unit/NativeReactorTest.php | 10 ++++++++++ 2 files changed, 10 insertions(+), 7 deletions(-) mode change 100644 => 100755 src/Alert/NativeReactor.php mode change 100644 => 100755 test/unit/NativeReactorTest.php diff --git a/src/Alert/NativeReactor.php b/src/Alert/NativeReactor.php old mode 100644 new mode 100755 index f54b775..516a15a --- a/src/Alert/NativeReactor.php +++ b/src/Alert/NativeReactor.php @@ -15,7 +15,6 @@ class NativeReactor implements Reactor { private $microsecondResolution = 1000000; private $lastWatcherId = 0; private $isRunning = FALSE; - private $garbage = []; private static $DISABLED_ALARM = 0; private static $DISABLED_READ = 1; @@ -78,8 +77,6 @@ class NativeReactor implements Reactor { if ($this->alarmOrder) { $this->executeAlarms(); } - - $this->garbage = []; } private function selectActionableStreams($sec, $usec) { @@ -225,8 +222,6 @@ class NativeReactor implements Reactor { private function cancelReadWatcher($watcherId) { $streamId = $this->watcherIdReadStreamIdMap[$watcherId]; - $this->garbage[] = $this->readCallbacks[$streamId][$watcherId]; - unset( $this->readCallbacks[$streamId][$watcherId], $this->watcherIdReadStreamIdMap[$watcherId], @@ -241,8 +236,6 @@ class NativeReactor implements Reactor { private function cancelWriteWatcher($watcherId) { $streamId = $this->watcherIdWriteStreamIdMap[$watcherId]; - $this->garbage[] = $this->writeCallbacks[$streamId][$watcherId]; - unset( $this->writeCallbacks[$streamId][$watcherId], $this->watcherIdWriteStreamIdMap[$watcherId], diff --git a/test/unit/NativeReactorTest.php b/test/unit/NativeReactorTest.php old mode 100644 new mode 100755 index 1035af7..cfd8e14 --- a/test/unit/NativeReactorTest.php +++ b/test/unit/NativeReactorTest.php @@ -266,6 +266,16 @@ class NativeReactorTest extends PHPUnit_Framework_TestCase { $reactor->once(function() use ($reactor) { $reactor->stop(); }, $delay = 0.01); $reactor->run(); } + + function testCancellationFromInsideWatcherCallback() { + $reactor = new NativeReactor; + $callback = function($watcherId, $reactor) { + $reactor->cancel($watcherId); + $reactor->stop(); + }; + $watcherId = $reactor->repeat($callback, $delay = 0.1); + $reactor->run(); + } function testOnWritableWatcher() { $reactor = new NativeReactor;