mirror of
https://github.com/danog/php-tokio.git
synced 2024-12-04 02:28:33 +01:00
29 lines
706 B
PHP
29 lines
706 B
PHP
|
<?php
|
||
|
|
||
|
namespace Reqwest;
|
||
|
|
||
|
final class Client {
|
||
|
private static ?string $id = null;
|
||
|
|
||
|
public static function register(): void {
|
||
|
if (self::$id !== null) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
$f = fopen("php://fd/".\reqwest_async_init(), 'r+');
|
||
|
stream_set_blocking($f, false);
|
||
|
self::$id = EventLoop::onReadable($f, fn () => \reqwest_async_wakeup());
|
||
|
}
|
||
|
|
||
|
public static function reference(): void{
|
||
|
EventLoop::reference(self::$id);
|
||
|
}
|
||
|
public static function unreference(): void {
|
||
|
EventLoop::unreference(self::$id);
|
||
|
}
|
||
|
|
||
|
public static function __callStatic(string $name, array $args): mixed {
|
||
|
return \Client::$name($args);
|
||
|
}
|
||
|
}
|