public function wait($unwrap = true) { $this->waitIfPending(); $inner = $this->result instanceof PromiseInterface ? $this->result->wait($unwrap) : $this->result; if ($unwrap) { if ($this->result instanceof PromiseInterface || $this->state === self::FULFILLED) { return $inner; } else { // It's rejected so "unwrap" and throw an exception. throw exception_for($inner); } } }
public function wait($unwrap = true) { $this->waitIfPending(); if (!$unwrap) { return null; } if ($this->result instanceof PromiseInterface) { return $this->result->wait($unwrap); } elseif ($this->state === self::FULFILLED) { return $this->result; } else { // It's rejected so "unwrap" and throw an exception. throw exception_for($this->result); } }
/** @internal */ function __next_coroutine($yielded, \Generator $generator) { return promise_for($yielded)->then(function ($value) use($generator) { $nextYield = $generator->send($value); return $generator->valid() ? __next_coroutine($nextYield, $generator) : $value; }, function ($reason) use($generator) { $nextYield = $generator->throw(exception_for($reason)); // The throw was caught, so keep iterating on the coroutine return __next_coroutine($nextYield, $generator); }); }
public function wait($unwrap = true, $defaultDelivery = null) { if ($unwrap) { throw exception_for($this->reason); } }