diff --git a/src/future/Future.php b/src/future/Future.php --- a/src/future/Future.php +++ b/src/future/Future.php @@ -25,13 +25,19 @@ * Resolve a future and return its result, blocking until the result is ready * if necessary. * - * @param float Optional timeout after which resolution will pause and - * execution will return to the caller. - * @return mixed Future result, or null if the timeout is hit. + * @return wild Future result. */ - public function resolve($timeout = null) { - $start = microtime(true); - $wait = $this->getDefaultWait(); + public function resolve() { + $args = func_get_args(); + if (count($args)) { + throw new Exception( + pht( + 'Parameter "timeout" to "Future->resolve()" is no longer '. + 'supported. Update the caller so it no longer passes a '. + 'timeout.')); + } + + $wait = $this->getDefaultWait(); do { $this->checkException(); if ($this->isReady()) { @@ -41,17 +47,6 @@ $read = $this->getReadSockets(); $write = $this->getWriteSockets(); - if ($timeout !== null) { - $elapsed = microtime(true) - $start; - - if ($elapsed > $timeout) { - $this->checkException(); - return null; - } else { - $wait = $timeout - $elapsed; - } - } - if ($read || $write) { self::waitForSockets($read, $write, $wait); } diff --git a/src/future/FutureProxy.php b/src/future/FutureProxy.php --- a/src/future/FutureProxy.php +++ b/src/future/FutureProxy.php @@ -30,8 +30,8 @@ return $this->getProxiedFuture()->isReady(); } - public function resolve($timeout = null) { - $this->getProxiedFuture()->resolve($timeout); + public function resolve() { + $this->getProxiedFuture()->resolve(); return $this->getResult(); } diff --git a/src/future/exec/ExecFuture.php b/src/future/exec/ExecFuture.php --- a/src/future/exec/ExecFuture.php +++ b/src/future/exec/ExecFuture.php @@ -231,15 +231,7 @@ /** * Permanently discard the stdout and stderr buffers and reset the read * cursors. This is basically useful only if you are streaming a large amount - * of data from some process: - * - * $future = new ExecFuture('zcat huge_file.gz'); - * do { - * $done = $future->resolve(0.1); // Every 100ms, - * list($stdout) = $future->read(); // read output... - * echo $stdout; // send it somewhere... - * $future->discardBuffers(); // and then free the buffers. - * } while ($done === null); + * of data from some process. * * Conceivably you might also need to do this if you're writing a client using * @{class:ExecFuture} and `netcat`, but you probably should not do that. @@ -316,8 +308,8 @@ * @return pair <$stdout, $stderr> pair. * @task resolve */ - public function resolvex($timeout = null) { - list($err, $stdout, $stderr) = $this->resolve($timeout); + public function resolvex() { + list($err, $stdout, $stderr) = $this->resolve(); if ($err) { $cmd = $this->getCommand(); @@ -352,8 +344,8 @@ * @return array PHP array, decoded from JSON command output. * @task resolve */ - public function resolveJSON($timeout = null) { - list($stdout, $stderr) = $this->resolvex($timeout); + public function resolveJSON() { + list($stdout, $stderr) = $this->resolvex(); if (strlen($stderr)) { $cmd = $this->getCommand(); throw new CommandException( diff --git a/src/future/exec/__tests__/ExecFutureTestCase.php b/src/future/exec/__tests__/ExecFutureTestCase.php --- a/src/future/exec/__tests__/ExecFutureTestCase.php +++ b/src/future/exec/__tests__/ExecFutureTestCase.php @@ -59,13 +59,18 @@ public function testResolveTimeoutTestShouldRunLessThan1Sec() { // NOTE: This tests interactions between the resolve() timeout and the - // ExecFuture timeout, which are similar but not identical. + // resolution timeout, which are somewhat similar but not identical. $future = $this->newSleep(32000)->start(); $future->setTimeout(32000); // We expect this to return in 0.01s. - $result = $future->resolve(0.01); + $iterator = (new FutureIterator(array($future))) + ->setUpdateInterval(0.01); + foreach ($iterator as $resolved_result) { + $result = $resolved_result; + break; + } $this->assertEqual($result, null); // We expect this to now force the time out / kill immediately. If we don't diff --git a/src/workflow/ArcanistWorkflow.php b/src/workflow/ArcanistWorkflow.php --- a/src/workflow/ArcanistWorkflow.php +++ b/src/workflow/ArcanistWorkflow.php @@ -1717,9 +1717,9 @@ return $parser; } - final protected function resolveCall(ConduitFuture $method, $timeout = null) { + final protected function resolveCall(ConduitFuture $method) { try { - return $method->resolve($timeout); + return $method->resolve(); } catch (ConduitClientException $ex) { if ($ex->getErrorCode() == 'ERR-CONDUIT-CALL') { echo phutil_console_wrap(