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:
parent
73fc260f15
commit
110e8f2fef
7
src/Alert/NativeReactor.php
Normal file → Executable file
7
src/Alert/NativeReactor.php
Normal file → Executable 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
10
test/unit/NativeReactorTest.php
Normal file → Executable 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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user