1
0
mirror of https://github.com/danog/amp.git synced 2025-01-22 05:11:42 +01:00

Removed unnecessary intermediary garbage storage

This commit is contained in:
Daniel Lowrey 2013-11-17 17:58:41 -05:00
parent 73fc260f15
commit 110e8f2fef
2 changed files with 10 additions and 7 deletions

7
src/Alert/NativeReactor.php Normal file → Executable file
View File

@ -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],

10
test/unit/NativeReactorTest.php Normal file → Executable file
View File

@ -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;