diff --git a/src/Adapter/Swoole/EventLoop.php b/src/Adapter/Swoole/EventLoop.php index 9132e76..bbaf8ba 100644 --- a/src/Adapter/Swoole/EventLoop.php +++ b/src/Adapter/Swoole/EventLoop.php @@ -9,6 +9,8 @@ use M6Web\Tornado\Promise; use Swoole\Coroutine; use Swoole\Event; +use RuntimeException; +use function extension_loaded; class EventLoop implements \M6Web\Tornado\EventLoop { @@ -20,6 +22,12 @@ class EventLoop implements \M6Web\Tornado\EventLoop public function __construct() { + if (!extension_loaded('swoole')) { + throw new RuntimeException( + 'SwoolePromise MUST running only in CLI mode with swoole extension.' + ); + } + $this->streamLoop = new Internal\StreamEventLoop(); $this->unhandledFailingPromises = new FailingPromiseCollection(); } diff --git a/src/Adapter/Swoole/Internal/SwoolePromise.php b/src/Adapter/Swoole/Internal/SwoolePromise.php index a38ac15..1a44749 100644 --- a/src/Adapter/Swoole/Internal/SwoolePromise.php +++ b/src/Adapter/Swoole/Internal/SwoolePromise.php @@ -4,12 +4,8 @@ use M6Web\Tornado\Promise; use Swoole\Coroutine; -use Swoole\Coroutine\Channel; use RuntimeException; -use function extension_loaded; use function count; -use function is_callable; -use function usleep; /** * @internal @@ -30,12 +26,6 @@ final class SwoolePromise implements Promise */ public function __construct(callable $executor) { - if (!extension_loaded('swoole')) { - throw new RuntimeException( - 'SwoolePromise MUST running only in CLI mode with swoole extension.' - ); - } - $this->onResolve = function($status, $value) { $this->result = [$status, $value]; };