mirror of
https://github.com/danog/amp.git
synced 2024-11-30 04:29:08 +01:00
Calling stop() in nested loop should not stop outer loop
This commit is contained in:
parent
a69bf4d3a0
commit
d7e8a9de84
12
lib/Loop.php
12
lib/Loop.php
@ -42,19 +42,19 @@ abstract class Loop extends Driver {
|
||||
private $errorHandler;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
* @var int
|
||||
*/
|
||||
private $running = false;
|
||||
private $running = 0;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function run() {
|
||||
$previous = $this->running;
|
||||
$this->running = true;
|
||||
++$this->running;
|
||||
|
||||
try {
|
||||
while ($this->running) {
|
||||
while ($this->running > $previous) {
|
||||
if ($this->isEmpty()) {
|
||||
return;
|
||||
}
|
||||
@ -69,7 +69,7 @@ abstract class Loop extends Driver {
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function stop() {
|
||||
$this->running = false;
|
||||
--$this->running > 0 ?: $this->running = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -414,7 +414,7 @@ abstract class Loop extends Driver {
|
||||
"on_readable" => $onReadable,
|
||||
"on_writable" => $onWritable,
|
||||
"on_signal" => $onSignal,
|
||||
"running" => $this->running,
|
||||
"running" => (bool) $this->running,
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user