From 39ca2fdf649fc490bb428bb92e725438b6a6d1d1 Mon Sep 17 00:00:00 2001 From: Joshua Spence Date: Tue, 30 Dec 2014 23:13:38 +1100 Subject: [PATCH] Use `new FutureIterator` instead of `Futures` Summary: Ref T6829. Deprecate the `Futures()` function. Test Plan: N/A Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T6829 Differential Revision: https://secure.phabricator.com/D11077 --- scripts/symbols/generate_ctags_symbols.php | 4 +++- scripts/symbols/generate_php_symbols.php | 4 +++- .../parser/DifferentialChangesetParser.php | 2 +- .../diffusion/DiffusionLintSaveRunner.php | 4 +++- .../conduit/DiffusionDiffQueryConduitAPIMethod.php | 2 +- .../conduit/DiffusionTagsQueryConduitAPIMethod.php | 3 ++- .../controller/DiffusionBrowseSearchController.php | 4 +++- .../diffusion/engine/DiffusionCommitHookEngine.php | 12 ++++++++---- .../lowlevel/DiffusionLowLevelResolveRefsQuery.php | 2 +- .../diviner/workflow/DivinerGenerateWorkflow.php | 4 +++- .../doorkeeper/bridge/DoorkeeperBridgeAsana.php | 2 +- .../doorkeeper/bridge/DoorkeeperBridgeJIRA.php | 2 +- .../step/HarbormasterBuildStepImplementation.php | 2 +- .../HarbormasterCommandBuildStepImplementation.php | 2 +- ...InternationalizationManagementExtractWorkflow.php | 5 ++++- .../lint/linter/PhabricatorJavelinLinter.php | 2 +- 16 files changed, 37 insertions(+), 19 deletions(-) diff --git a/scripts/symbols/generate_ctags_symbols.php b/scripts/symbols/generate_ctags_symbols.php index 6c52521d7e..c70c408bd6 100755 --- a/scripts/symbols/generate_ctags_symbols.php +++ b/scripts/symbols/generate_ctags_symbols.php @@ -30,7 +30,9 @@ foreach ($input as $file) { $futures[$file] = ctags_get_parser_future($file); } -foreach (Futures($futures)->limit(8) as $file => $future) { +$futures = id(new FutureIterator($futures)) + ->limit(8); +foreach ($futures as $file => $future) { $tags = $future->resolve(); $tags = explode("\n", $tags[1]); diff --git a/scripts/symbols/generate_php_symbols.php b/scripts/symbols/generate_php_symbols.php index 087898fdda..4129af557c 100755 --- a/scripts/symbols/generate_php_symbols.php +++ b/scripts/symbols/generate_php_symbols.php @@ -23,7 +23,9 @@ foreach ($input as $file) { $futures[$file] = xhpast_get_parser_future($data[$file]); } -foreach (Futures($futures)->limit(8) as $file => $future) { +$futures = id(new FutureIterator($futures)) + ->limit(8); +foreach ($futures as $file => $future) { $tree = XHPASTTree::newFromDataAndResolvedExecFuture( $data[$file], $future->resolve()); diff --git a/src/applications/differential/parser/DifferentialChangesetParser.php b/src/applications/differential/parser/DifferentialChangesetParser.php index 9db301ab35..a27f8c823b 100644 --- a/src/applications/differential/parser/DifferentialChangesetParser.php +++ b/src/applications/differential/parser/DifferentialChangesetParser.php @@ -653,7 +653,7 @@ final class DifferentialChangesetParser { ); $this->highlightErrors = false; - foreach (Futures($futures) as $key => $future) { + foreach (new FutureIterator($futures) as $key => $future) { try { try { $highlighted = $future->resolve(); diff --git a/src/applications/diffusion/DiffusionLintSaveRunner.php b/src/applications/diffusion/DiffusionLintSaveRunner.php index 23bc70a2ef..6adcde8dda 100644 --- a/src/applications/diffusion/DiffusionLintSaveRunner.php +++ b/src/applications/diffusion/DiffusionLintSaveRunner.php @@ -250,7 +250,9 @@ final class DiffusionLintSaveRunner { $authors = array(); - foreach (Futures($futures)->limit(8) as $path => $future) { + $futures = id(new FutureIterator($futures)) + ->limit(8); + foreach ($futures as $path => $future) { $queries[$path]->loadFileContentFromFuture($future); list(, $rev_list, $blame_dict) = $queries[$path]->getBlameData(); foreach (array_keys($this->blame[$path]) as $line) { diff --git a/src/applications/diffusion/conduit/DiffusionDiffQueryConduitAPIMethod.php b/src/applications/diffusion/conduit/DiffusionDiffQueryConduitAPIMethod.php index c0b311c8eb..4dc2a2bac9 100644 --- a/src/applications/diffusion/conduit/DiffusionDiffQueryConduitAPIMethod.php +++ b/src/applications/diffusion/conduit/DiffusionDiffQueryConduitAPIMethod.php @@ -129,7 +129,7 @@ final class DiffusionDiffQueryConduitAPIMethod ); $futures = array_filter($futures); - foreach (Futures($futures) as $key => $future) { + foreach (new FutureIterator($futures) as $key => $future) { $stdout = ''; try { list($stdout) = $future->resolvex(); diff --git a/src/applications/diffusion/conduit/DiffusionTagsQueryConduitAPIMethod.php b/src/applications/diffusion/conduit/DiffusionTagsQueryConduitAPIMethod.php index 4f8d6a959f..1ece4dd85b 100644 --- a/src/applications/diffusion/conduit/DiffusionTagsQueryConduitAPIMethod.php +++ b/src/applications/diffusion/conduit/DiffusionTagsQueryConduitAPIMethod.php @@ -129,7 +129,8 @@ final class DiffusionTagsQueryConduitAPIMethod $tag->getName()); } - Futures($futures)->resolveAll(); + id(new FutureIterator($futures)) + ->resolveAll(); foreach ($tags as $key => $tag) { $future = $futures[$key]; diff --git a/src/applications/diffusion/controller/DiffusionBrowseSearchController.php b/src/applications/diffusion/controller/DiffusionBrowseSearchController.php index 16bb1bc761..8b6f91c38e 100644 --- a/src/applications/diffusion/controller/DiffusionBrowseSearchController.php +++ b/src/applications/diffusion/controller/DiffusionBrowseSearchController.php @@ -132,7 +132,9 @@ final class DiffusionBrowseSearchController extends DiffusionBrowseController { } try { - Futures($futures)->limit(8)->resolveAll(); + id(new FutureIterator($futures)) + ->limit(8) + ->resolveAll(); } catch (PhutilSyntaxHighlighterException $ex) {} $rows = array(); diff --git a/src/applications/diffusion/engine/DiffusionCommitHookEngine.php b/src/applications/diffusion/engine/DiffusionCommitHookEngine.php index c4d509fdb8..080a69c306 100644 --- a/src/applications/diffusion/engine/DiffusionCommitHookEngine.php +++ b/src/applications/diffusion/engine/DiffusionCommitHookEngine.php @@ -445,7 +445,9 @@ final class DiffusionCommitHookEngine extends Phobject { $ref_new); } - foreach (Futures($futures)->limit(8) as $key => $future) { + $futures = id(new FutureIterator($futures)) + ->limit(8); + foreach ($futures as $key => $future) { // If 'old' and 'new' have no common ancestors (for example, a force push // which completely rewrites a ref), `git merge-base` will exit with @@ -554,7 +556,9 @@ final class DiffusionCommitHookEngine extends Phobject { } $content_updates = array(); - foreach (Futures($futures)->limit(8) as $key => $future) { + $futures = id(new FutureIterator($futures)) + ->limit(8); + foreach ($futures as $key => $future) { list($stdout) = $future->resolvex(); if (!strlen(trim($stdout))) { @@ -709,7 +713,7 @@ final class DiffusionCommitHookEngine extends Phobject { // Resolve all of the futures now. We don't need the 'commits' future yet, // but it simplifies the logic to just get it out of the way. - foreach (Futures($futures) as $future) { + foreach (new FutureIterator($futures) as $future) { $future->resolve(); } @@ -782,7 +786,7 @@ final class DiffusionCommitHookEngine extends Phobject { } $head_map = array(); - foreach (Futures($dfutures) as $future_head => $dfuture) { + foreach (new FutureIterator($dfutures) as $future_head => $dfuture) { list($stdout) = $dfuture->resolvex(); $descendant_heads = array_filter(explode("\1", $stdout)); if ($descendant_heads) { diff --git a/src/applications/diffusion/query/lowlevel/DiffusionLowLevelResolveRefsQuery.php b/src/applications/diffusion/query/lowlevel/DiffusionLowLevelResolveRefsQuery.php index ca47c04ca1..72f2d18533 100644 --- a/src/applications/diffusion/query/lowlevel/DiffusionLowLevelResolveRefsQuery.php +++ b/src/applications/diffusion/query/lowlevel/DiffusionLowLevelResolveRefsQuery.php @@ -142,7 +142,7 @@ final class DiffusionLowLevelResolveRefsQuery } $results = array(); - foreach (Futures($futures) as $ref => $future) { + foreach (new FutureIterator($futures) as $ref => $future) { try { list($stdout) = $future->resolvex(); } catch (CommandException $ex) { diff --git a/src/applications/diviner/workflow/DivinerGenerateWorkflow.php b/src/applications/diviner/workflow/DivinerGenerateWorkflow.php index 7a75f744ab..bc799af303 100644 --- a/src/applications/diviner/workflow/DivinerGenerateWorkflow.php +++ b/src/applications/diviner/workflow/DivinerGenerateWorkflow.php @@ -333,7 +333,9 @@ final class DivinerGenerateWorkflow extends DivinerWorkflow { $atom_cache = $this->getAtomCache(); $bar = id(new PhutilConsoleProgressBar()) ->setTotal(count($futures)); - foreach (Futures($futures)->limit(4) as $key => $future) { + $futures = id(new FutureIterator($futures)) + ->limit(4); + foreach ($futures as $key => $future) { try { $atoms = $future->resolveJSON(); diff --git a/src/applications/doorkeeper/bridge/DoorkeeperBridgeAsana.php b/src/applications/doorkeeper/bridge/DoorkeeperBridgeAsana.php index 79e711e00a..4e32239793 100644 --- a/src/applications/doorkeeper/bridge/DoorkeeperBridgeAsana.php +++ b/src/applications/doorkeeper/bridge/DoorkeeperBridgeAsana.php @@ -70,7 +70,7 @@ final class DoorkeeperBridgeAsana extends DoorkeeperBridge { $results = array(); $failed = array(); - foreach (Futures($futures) as $key => $future) { + foreach (new FutureIterator($futures) as $key => $future) { try { $results[$key] = $future->resolve(); } catch (Exception $ex) { diff --git a/src/applications/doorkeeper/bridge/DoorkeeperBridgeJIRA.php b/src/applications/doorkeeper/bridge/DoorkeeperBridgeJIRA.php index 6349943770..c9b40d2e72 100644 --- a/src/applications/doorkeeper/bridge/DoorkeeperBridgeJIRA.php +++ b/src/applications/doorkeeper/bridge/DoorkeeperBridgeJIRA.php @@ -57,7 +57,7 @@ final class DoorkeeperBridgeJIRA extends DoorkeeperBridge { $results = array(); $failed = array(); - foreach (Futures($futures) as $key => $future) { + foreach (new FutureIterator($futures) as $key => $future) { try { $results[$key] = $future->resolveJSON(); } catch (Exception $ex) { diff --git a/src/applications/harbormaster/step/HarbormasterBuildStepImplementation.php b/src/applications/harbormaster/step/HarbormasterBuildStepImplementation.php index 3933cd5086..5057097fac 100644 --- a/src/applications/harbormaster/step/HarbormasterBuildStepImplementation.php +++ b/src/applications/harbormaster/step/HarbormasterBuildStepImplementation.php @@ -234,7 +234,7 @@ abstract class HarbormasterBuildStepImplementation { HarbormasterBuildTarget $target, Future $future) { - $futures = Futures(array($future)); + $futures = new FutureIterator(array($future)); foreach ($futures->setUpdateInterval(5) as $key => $future) { if ($future === null) { $build->reload(); diff --git a/src/applications/harbormaster/step/HarbormasterCommandBuildStepImplementation.php b/src/applications/harbormaster/step/HarbormasterCommandBuildStepImplementation.php index 806e311083..14fc65a76c 100644 --- a/src/applications/harbormaster/step/HarbormasterCommandBuildStepImplementation.php +++ b/src/applications/harbormaster/step/HarbormasterCommandBuildStepImplementation.php @@ -65,7 +65,7 @@ final class HarbormasterCommandBuildStepImplementation $build_update = 5; // Read the next amount of available output every second. - $futures = Futures(array($future)); + $futures = new FutureIterator(array($future)); foreach ($futures->setUpdateInterval(1) as $key => $future_iter) { if ($future_iter === null) { diff --git a/src/infrastructure/internationalization/management/PhabricatorInternationalizationManagementExtractWorkflow.php b/src/infrastructure/internationalization/management/PhabricatorInternationalizationManagementExtractWorkflow.php index 6aca557188..e2819d1f28 100644 --- a/src/infrastructure/internationalization/management/PhabricatorInternationalizationManagementExtractWorkflow.php +++ b/src/infrastructure/internationalization/management/PhabricatorInternationalizationManagementExtractWorkflow.php @@ -43,7 +43,10 @@ final class PhabricatorInternationalizationManagementExtractWorkflow $bar = id(new PhutilConsoleProgressBar()) ->setTotal(count($futures)); - foreach (Futures($futures)->limit(8) as $full_path => $future) { + + $futures = id(new FutureIterator($futures)) + ->limit(8); + foreach ($futures as $full_path => $future) { $bar->update(1); $tree = XHPASTTree::newFromDataAndResolvedExecFuture( diff --git a/src/infrastructure/lint/linter/PhabricatorJavelinLinter.php b/src/infrastructure/lint/linter/PhabricatorJavelinLinter.php index c69d8aacbc..4a2298a72a 100644 --- a/src/infrastructure/lint/linter/PhabricatorJavelinLinter.php +++ b/src/infrastructure/lint/linter/PhabricatorJavelinLinter.php @@ -50,7 +50,7 @@ final class PhabricatorJavelinLinter extends ArcanistLinter { $futures[$path] = $future; } - foreach (Futures($futures)->limit(8) as $path => $future) { + foreach (id(new FutureIterator($futures))->limit(8) as $path => $future) { $this->symbols[$path] = $future->resolvex(); } }