Changeset View
Changeset View
Standalone View
Standalone View
src/future/FutureProxy.php
| Show All 21 Lines | abstract class FutureProxy extends Future { | ||||
| protected function getProxiedFuture() { | protected function getProxiedFuture() { | ||||
| if (!$this->proxied) { | if (!$this->proxied) { | ||||
| throw new Exception(pht('The proxied future has not been provided yet.')); | throw new Exception(pht('The proxied future has not been provided yet.')); | ||||
| } | } | ||||
| return $this->proxied; | return $this->proxied; | ||||
| } | } | ||||
| public function isReady() { | public function isReady() { | ||||
| if ($this->hasResult()) { | if ($this->hasResult() || $this->hasException()) { | ||||
| return true; | return true; | ||||
| } | } | ||||
| $proxied = $this->getProxiedFuture(); | $proxied = $this->getProxiedFuture(); | ||||
| $proxied->updateFuture(); | |||||
| $is_ready = $proxied->isReady(); | if ($proxied->hasResult() || $proxied->hasException()) { | ||||
| try { | |||||
| if ($proxied->hasResult()) { | $result = $proxied->resolve(); | ||||
| $result = $proxied->getResult(); | |||||
| $result = $this->didReceiveResult($result); | $result = $this->didReceiveResult($result); | ||||
| $this->setResult($result); | } catch (Exception $ex) { | ||||
| $result = $this->didReceiveException($ex); | |||||
| } catch (Throwable $ex) { | |||||
| $result = $this->didReceiveException($ex); | |||||
| } | } | ||||
| return $is_ready; | $this->setResult($result); | ||||
| return true; | |||||
| } | } | ||||
| public function resolve() { | return false; | ||||
| $this->getProxiedFuture()->resolve(); | |||||
| $this->isReady(); | |||||
| return $this->getResult(); | |||||
| } | } | ||||
| public function getReadSockets() { | public function getReadSockets() { | ||||
| return $this->getProxiedFuture()->getReadSockets(); | return $this->getProxiedFuture()->getReadSockets(); | ||||
| } | } | ||||
| public function getWriteSockets() { | public function getWriteSockets() { | ||||
| return $this->getProxiedFuture()->getWriteSockets(); | return $this->getProxiedFuture()->getWriteSockets(); | ||||
| Show All 9 Lines | abstract class FutureProxy extends Future { | ||||
| } | } | ||||
| protected function getServiceProfilerResultParameters() { | protected function getServiceProfilerResultParameters() { | ||||
| return $this->getProxiedFuture()->getServiceProfilerResultParameters(); | return $this->getProxiedFuture()->getServiceProfilerResultParameters(); | ||||
| } | } | ||||
| abstract protected function didReceiveResult($result); | abstract protected function didReceiveResult($result); | ||||
| protected function didReceiveException($exception) { | |||||
| throw $exception; | |||||
| } | |||||
| } | } | ||||