1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-26 00:32:41 +01:00

Use new FutureIterator instead of Futures

Summary: Ref T6829. Deprecate the `Futures()` function.

Test Plan: N/A

Reviewers: epriestley, #blessed_reviewers

Reviewed By: epriestley, #blessed_reviewers

Subscribers: aurelijus, Korvin, epriestley

Maniphest Tasks: T6829

Differential Revision: https://secure.phabricator.com/D11079
This commit is contained in:
Joshua Spence 2014-12-30 23:14:32 +11:00
parent 841556134f
commit 721bdf424b
11 changed files with 39 additions and 17 deletions

View file

@ -184,7 +184,9 @@ final class ArcanistCSharpLinter extends ArcanistLinter {
public function didRunLinters() { public function didRunLinters() {
if ($this->futures) { if ($this->futures) {
foreach (Futures($this->futures)->limit(8) as $future) { $futures = id(new FutureIterator($this->futures))
->limit(8);
foreach ($futures as $future) {
$this->resolveFuture($future); $this->resolveFuture($future);
} }
} }

View file

@ -13,7 +13,7 @@ abstract class ArcanistFutureLinter extends ArcanistLinter {
final public function willLintPaths(array $paths) { final public function willLintPaths(array $paths) {
$limit = $this->getFuturesLimit(); $limit = $this->getFuturesLimit();
$this->futures = Futures(array())->limit($limit); $this->futures = id(new FutureIterator(array()))->limit($limit);
foreach ($this->buildFutures($paths) as $path => $future) { foreach ($this->buildFutures($paths) as $path => $future) {
$this->futures->addFuture($future, $path); $this->futures->addFuture($future, $path);
} }

View file

@ -187,7 +187,9 @@ final class ArcanistScriptAndRegexLinter extends ArcanistLinter {
$futures[$path] = $future; $futures[$path] = $future;
} }
foreach (Futures($futures)->limit(4) as $path => $future) { $futures = id(new FutureIterator($futures))
->limit(4);
foreach ($futures as $path => $future) {
list($stdout) = $future->resolvex(); list($stdout) = $future->resolvex();
$this->output[$path] = $stdout; $this->output[$path] = $stdout;
} }

View file

@ -609,7 +609,7 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI {
// After the other commands exit, we can start the `diff-files` command. // After the other commands exit, we can start the `diff-files` command.
); );
Futures($futures)->resolveAll(); id(new FutureIterator($futures))->resolveAll();
// We're clear to start the `git diff-files` now. // We're clear to start the `git diff-files` now.
$unstaged_future->start(); $unstaged_future->start();

View file

@ -284,7 +284,9 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI {
$last_node = $node; $last_node = $node;
} }
foreach (Futures($futures)->limit(4) as $node => $future) { $futures = id(new FutureIterator($futures))
->limit(4);
foreach ($futures as $node => $future) {
list($parents) = $future->resolvex(); list($parents) = $future->resolvex();
$parents = array_filter(explode("\n", $parents)); $parents = array_filter(explode("\n", $parents));
$commits[$node]['parents'] = $parents; $commits[$node]['parents'] = $parents;

View file

@ -59,7 +59,9 @@ final class NoseTestEngine extends ArcanistUnitTestEngine {
} }
$results = array(); $results = array();
foreach (Futures($futures)->limit(4) as $test_path => $future) { $futures = id(new FutureIterator($futures))
->limit(4);
foreach ($futures as $test_path => $future) {
try { try {
list($stdout, $stderr) = $future->resolvex(); list($stdout, $stderr) = $future->resolvex();
} catch(CommandException $exc) { } catch(CommandException $exc) {

View file

@ -73,7 +73,9 @@ final class PhpunitTestEngine extends ArcanistUnitTestEngine {
} }
$results = array(); $results = array();
foreach (Futures($futures)->limit(4) as $test => $future) { $futures = id(new FutureIterator($futures))
->limit(4);
foreach ($futures as $test => $future) {
list($err, $stdout, $stderr) = $future->resolve(); list($err, $stdout, $stderr) = $future->resolve();

View file

@ -277,7 +277,7 @@ class XUnitTestEngine extends ArcanistUnitTestEngine {
dirname($test_assembly['project']))); dirname($test_assembly['project'])));
$build_futures[$test_assembly['project']] = $build_future; $build_futures[$test_assembly['project']] = $build_future;
} }
$iterator = Futures($build_futures)->limit(1); $iterator = id(new FutureIterator($build_futures))->limit(1);
foreach ($iterator as $test_assembly => $future) { foreach ($iterator as $test_assembly => $future) {
$result = new ArcanistUnitTestResult(); $result = new ArcanistUnitTestResult();
$result->setName('(build) '.$test_assembly); $result->setName('(build) '.$test_assembly);
@ -353,7 +353,9 @@ class XUnitTestEngine extends ArcanistUnitTestEngine {
} }
// Run all of the tests. // Run all of the tests.
foreach (Futures($futures)->limit(8) as $test_assembly => $future) { $futures = id(new FutureIterator($futures))
->limit(8);
foreach ($futures as $test_assembly => $future) {
list($err, $stdout, $stderr) = $future->resolve(); list($err, $stdout, $stderr) = $future->resolve();
if (file_exists($outputs[$test_assembly])) { if (file_exists($outputs[$test_assembly])) {

View file

@ -1135,7 +1135,9 @@ EOTEXT
$targets[] = array('command' => 'info', 'path' => $path); $targets[] = array('command' => 'info', 'path' => $path);
} }
foreach (Futures($futures)->limit(8) as $key => $future) { $futures = id(new FutureIterator($futures))
->limit(8);
foreach ($futures as $key => $future) {
$target = $targets[$key]; $target = $targets[$key];
if ($target['command'] == 'diff') { if ($target['command'] == 'diff') {
$repository_api->primeSVNDiffResult( $repository_api->primeSVNDiffResult(
@ -1774,7 +1776,7 @@ EOTEXT
)); ));
} }
foreach (Futures($futures) as $key => $future) { foreach (new FutureIterator($futures) as $key => $future) {
$result = $future->resolve(); $result = $future->resolve();
switch ($key) { switch ($key) {
case 'revision': case 'revision':
@ -2393,7 +2395,8 @@ EOTEXT
* @task diffprop * @task diffprop
*/ */
private function resolveDiffPropertyUpdates() { private function resolveDiffPropertyUpdates() {
Futures($this->diffPropertyFutures)->resolveAll(); id(new FutureIterator($this->diffPropertyFutures))
->resolveAll();
$this->diffPropertyFutures = array(); $this->diffPropertyFutures = array();
} }
@ -2522,7 +2525,9 @@ EOTEXT
)); ));
} }
foreach (Futures($hash_futures)->limit(8) as $key => $future) { $futures = id(new FutureIterator($hash_futures))
->limit(8);
foreach ($futures as $key => $future) {
$type = $need_upload[$key]['type']; $type = $need_upload[$key]['type'];
$change = $need_upload[$key]['change']; $change = $need_upload[$key]['change'];
$name = $need_upload[$key]['name']; $name = $need_upload[$key]['name'];
@ -2553,7 +2558,9 @@ EOTEXT
)); ));
} }
foreach (Futures($upload_futures)->limit(4) as $key => $future) { $futures = id(new FutureIterator($upload_futures))
->limit(4);
foreach ($futures as $key => $future) {
$type = $need_upload[$key]['type']; $type = $need_upload[$key]['type'];
$change = $need_upload[$key]['change']; $change = $need_upload[$key]['change'];
$name = $need_upload[$key]['name']; $name = $need_upload[$key]['name'];

View file

@ -191,7 +191,9 @@ EOTEXT
$branches = ipull($branches, null, 'name'); $branches = ipull($branches, null, 'name');
foreach (Futures($futures)->limit(16) as $name => $future) { $futures = id(new FutureIterator($futures))
->limit(16);
foreach ($futures as $name => $future) {
list($info) = $future->resolvex(); list($info) = $future->resolvex();
list($hash, $epoch, $tree, $desc, $text) = explode("\1", trim($info), 5); list($hash, $epoch, $tree, $desc, $text) = explode("\1", trim($info), 5);
@ -250,7 +252,7 @@ EOTEXT
} }
$results = array(); $results = array();
foreach (Futures($calls) as $call) { foreach (new FutureIterator($calls) as $call) {
$results[] = $call->resolve(); $results[] = $call->resolve();
} }

View file

@ -113,7 +113,8 @@ EOTEXT
)); ));
} }
Futures($futures)->resolveAll(); id(new FutureIterator($futures))
->resolveAll();
return 0; return 0;
} }