1
0
mirror of https://github.com/danog/amp.git synced 2024-12-12 09:29:45 +01:00

Remove registry data and error handler when clearing loop

This commit is contained in:
Aaron Piotrowski 2020-10-07 22:52:23 -05:00
parent cecbbd3f40
commit 8ee7d61452
No known key found for this signature in database
GPG Key ID: ADD1EF783EDE9EEB

View File

@ -37,7 +37,7 @@ abstract class Driver implements \FiberScheduler
private array $nextTickQueue = []; private array $nextTickQueue = [];
/** @var callable(\Throwable):void|null */ /** @var callable(\Throwable):void|null */
private $errorHandler; private $errorHandler = null;
/** @var mixed[] */ /** @var mixed[] */
private array $registry = []; private array $registry = [];
@ -645,14 +645,17 @@ abstract class Driver implements \FiberScheduler
} }
/** /**
* Removes all watchers from the event loop. This method is intended for clearing the loop between * Removes all watchers, registry data, and error handler from the event loop. This method is intended for
* tests and not intended for use in an application. * clearing the loop between tests and not intended for use in an application.
*/ */
final public function clear(): void final public function clear(): void
{ {
foreach ($this->watchers as $watcher) { foreach ($this->watchers as $watcher) {
$this->cancel($watcher->id); $this->cancel($watcher->id);
} }
$this->registry = [];
$this->errorHandler = null;
} }
/** /**