Changeset View
Changeset View
Standalone View
Standalone View
src/applications/harbormaster/future/HarbormasterExecFuture.php
| Show All 19 Lines | public function setLogs( | ||||
| HarbormasterBuildLog $stdout, | HarbormasterBuildLog $stdout, | ||||
| HarbormasterBuildLog $stderr) { | HarbormasterBuildLog $stderr) { | ||||
| $this->stdout = $stdout; | $this->stdout = $stdout; | ||||
| $this->stderr = $stderr; | $this->stderr = $stderr; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function isReady() { | public function isReady() { | ||||
| if ($this->hasResult()) { | |||||
| return true; | |||||
| } | |||||
| $future = $this->getFuture(); | $future = $this->getFuture(); | ||||
| $result = $future->isReady(); | $is_ready = $future->isReady(); | ||||
| list($stdout, $stderr) = $future->read(); | list($stdout, $stderr) = $future->read(); | ||||
| $future->discardBuffers(); | $future->discardBuffers(); | ||||
| if ($this->stdout) { | if ($this->stdout) { | ||||
| $this->stdout->append($stdout); | $this->stdout->append($stdout); | ||||
| } | } | ||||
| if ($this->stderr) { | if ($this->stderr) { | ||||
| $this->stderr->append($stderr); | $this->stderr->append($stderr); | ||||
| } | } | ||||
| return $result; | if ($future->hasResult()) { | ||||
| $this->setResult($future->getResult()); | |||||
| } | } | ||||
| protected function getResult() { | // TODO: This should probably be implemented as a FutureProxy; it will | ||||
| return $this->getFuture()->getResult(); | // not currently propagate exceptions or sockets properly. | ||||
| return $is_ready; | |||||
| } | } | ||||
| } | } | ||||