/** * Remove promise from runner * * @param PromiseCore $core */ public function remove(PromiseCore $core) { foreach ($this->cores as $index => $existed) { if ($existed === $core) { curl_multi_remove_handle($this->multiHandle, $core->getHandle()); unset($this->cores[$index]); return; } } }
/** * Wait for the promise to be fulfilled or rejected. * * When this method returns, the request has been resolved and the appropriate callable has terminated. * * When called with the unwrap option * * @param bool $unwrap Whether to return resolved value / throw reason or not * * @return \Psr\Http\Message\ResponseInterface|null Resolved value, null if $unwrap is set to false * * @throws \Http\Client\Exception The rejection reason. */ public function wait($unwrap = true) { $this->runner->wait($this->core); if ($unwrap) { if ($this->core->getState() === self::REJECTED) { throw $this->core->getException(); } return $this->core->getResponse(); } return null; }