You are here

public function Coroutine::__construct in Lockr 7.3

File

vendor/guzzlehttp/promises/src/Coroutine.php, line 60

Class

Coroutine
Creates a promise that is resolved using a generator that yields values or promises (somewhat similar to C#'s async keyword).

Namespace

GuzzleHttp\Promise

Code

public function __construct(callable $generatorFn) {
  $this->generator = $generatorFn();
  $this->result = new Promise(function () {
    while (isset($this->currentPromise)) {
      $this->currentPromise
        ->wait();
    }
  });
  $this
    ->nextCoroutine($this->generator
    ->current());
}