-
-
Notifications
You must be signed in to change notification settings - Fork 261
Closed
Labels
Description
The code below works as I would expect: it completes. But if I replace the bar with baz on line 42, the program no longer completes, because in this case a reference to the Foo remains somewhere inside the library. This doesn't seem to be the expected behavior.
<?php
declare (strict_types = 1);
use Revolt\EventLoop;
require 'vendor/autoload.php';
final class Foo
{
private readonly string $id;
public function __construct()
{
/** @var \Closure */
$f = Amp\weakClosure(function (): void {
echo "...\n";
});
$this->id = EventLoop::repeat(1, $f);
}
public function __destruct()
{
EventLoop::cancel($this->id);
}
public function bar(): string
{
return 'OK';
}
public function baz(): never
{
throw new Exception();
}
}
(function (): void {
$foo = new Foo();
var_dump(Amp\Future\awaitAll([
Amp\async($foo->bar(...)),
]));
})();
EventLoop::run();