Skip to content

Commit

Permalink
👷 travis CI
Browse files Browse the repository at this point in the history
  • Loading branch information
matyo91 committed Apr 24, 2021
1 parent 0dead13 commit ca47e61
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 30 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ before_script:
- phpenv config-rm xdebug.ini
- composer install

before_install:
- printf "\n" | pecl install swoole

env:
- TASK=tests-unit
- TASK=tests-examples
Expand Down
1 change: 0 additions & 1 deletion src/Adapter/Swoole/EventLoop.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ private function pushCoroutine(): void
$cid = Coroutine::getCid();
$this->cids[] = $cid;
Coroutine::yield();

}

private function createPromise(): DummyPromise
Expand Down
16 changes: 4 additions & 12 deletions src/Adapter/Swoole/Internal/DummyPromise.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,16 @@

final class DummyPromise implements Promise, Deferred
{
/**
* @var bool
*/
/** @var bool */
private $isPending;

/**
* @var mixed
*/
/** @var mixed */
private $value;

/**
* @var Throwable|null
*/
/** @var Throwable|null */
private $exception;

/**
* @var callable[]
*/
/** @var callable[] */
private $callbacks;

public function __construct(?callable $callback = null)
Expand Down
7 changes: 4 additions & 3 deletions src/Adapter/Swoole/YieldEventLoop.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,12 @@ public function async(\Generator $generator): Promise
Coroutine::create(function () use ($generator, $deferred, $fnWrapGenerator) {
if (!$generator->valid()) {
$deferred->resolve($generator->getReturn());

return;
}

$promise = DummyPromise::wrap($generator->current());
if($this->isPending($promise)) {
if ($this->isPending($promise)) {
$cid = Coroutine::getCid();
$promise->addCallback(function () use ($cid) {
Coroutine::resume($cid);
Expand All @@ -96,15 +97,15 @@ public function promiseAll(Promise ...$promises): Promise
$wg = new Coroutine\WaitGroup();
$result = [];
foreach ($promises as $index => $promise) {
$this->async((static function() use($wg, &$result, $index, $promise){
$this->async((static function () use ($wg, &$result, $index, $promise) {
$wg->add();
$result[$index] = yield $promise;
$wg->done();
})());
}

$deferred = $this->deferred();
Coroutine::create(function() use($wg, $deferred, &$result) {
Coroutine::create(function () use ($wg, $deferred, &$result) {
$wg->wait();
$deferred->resolve($result);
});
Expand Down
14 changes: 0 additions & 14 deletions tests/Adapter/Swoole/YieldEventLoopTest.php

This file was deleted.

0 comments on commit ca47e61

Please sign in to comment.