mirror of
https://github.com/danog/amp.git
synced 2024-12-11 17:09:40 +01:00
45bd189e76
Intended for tests over swapping the entire event loop. This allows forbidding swapping the global event loop once it is started.
38 lines
712 B
PHP
38 lines
712 B
PHP
--TEST--
|
|
Test order of destruction not interfering with access to UV handles
|
|
--SKIPIF--
|
|
<?php
|
|
\extension_loaded("uv") or die("SKIP: ext/uv required for this test");
|
|
?>
|
|
--FILE--
|
|
<?php
|
|
|
|
include __DIR__.'/../../vendor/autoload.php';
|
|
|
|
use Amp\Loop\UvDriver;
|
|
|
|
$loop = new UvDriver;
|
|
|
|
$loop->setState('test', new class($loop) {
|
|
private UvDriver $loop;
|
|
private string $handle;
|
|
public function __construct(UvDriver $loop)
|
|
{
|
|
$this->loop = $loop;
|
|
$this->handle = $this->loop->repeat(10, function () {});
|
|
}
|
|
public function __destruct()
|
|
{
|
|
$this->loop->cancel($this->handle);
|
|
print "ok";
|
|
}
|
|
});
|
|
|
|
$loop->delay(0, [$loop, "stop"]);
|
|
|
|
$loop->run();
|
|
|
|
?>
|
|
--EXPECT--
|
|
ok
|