Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(166)

Side by Side Diff: pkg/polymer/lib/src/build/runner.dart

Issue 26273003: Pool future creation to ensure no more than 10 ops are in flight (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: using in polymer Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/barback/lib/src/utils.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** 5 /**
6 * Definitions used to run the polymer linter and deploy tools without using 6 * Definitions used to run the polymer linter and deploy tools without using
7 * pub serve or pub deploy. 7 * pub serve or pub deploy.
8 */ 8 */
9 library polymer.src.build.runner; 9 library polymer.src.build.runner;
10 10
11 import 'dart:async'; 11 import 'dart:async';
12 import 'dart:convert'; 12 import 'dart:convert';
13 import 'dart:io'; 13 import 'dart:io';
14 14
15 import 'package:args/args.dart'; 15 import 'package:args/args.dart';
16 import 'package:barback/barback.dart'; 16 import 'package:barback/barback.dart';
17 import 'package:barback/src/utils.dart' show forEachPooledFuture;
17 import 'package:path/path.dart' as path; 18 import 'package:path/path.dart' as path;
18 import 'package:stack_trace/stack_trace.dart'; 19 import 'package:stack_trace/stack_trace.dart';
19 import 'package:yaml/yaml.dart'; 20 import 'package:yaml/yaml.dart';
20 21
21 22
22 /** Collects different parameters needed to configure and run barback. */ 23 /** Collects different parameters needed to configure and run barback. */
23 class BarbackOptions { 24 class BarbackOptions {
24 /** Phases of transformers to run. */ 25 /** Phases of transformers to run. */
25 final List<List<Transformer>> phases; 26 final List<List<Transformer>> phases;
26 27
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 }); 205 });
205 } 206 }
206 207
207 Future _emitTransformedFiles(AssetSet assets, BarbackOptions options) { 208 Future _emitTransformedFiles(AssetSet assets, BarbackOptions options) {
208 // Copy all the assets we transformed 209 // Copy all the assets we transformed
209 var futures = []; 210 var futures = [];
210 var currentPackage = options.currentPackage; 211 var currentPackage = options.currentPackage;
211 var transformTests = options.transformTests; 212 var transformTests = options.transformTests;
212 var outPackages = path.join(options.outDir, 'packages'); 213 var outPackages = path.join(options.outDir, 'packages');
213 214
214 return Future.forEach(assets, (asset) { 215 return forEachPooledFuture(assets, (asset) {
215 var id = asset.id; 216 var id = asset.id;
216 var dir = _firstDir(id.path); 217 var dir = _firstDir(id.path);
217 if (dir == null) return null; 218 if (dir == null) return null;
218 219
219 var filepath; 220 var filepath;
220 if (dir == 'lib') { 221 if (dir == 'lib') {
221 // Put lib files directly under the packages folder (e.g. 'lib/foo.dart' 222 // Put lib files directly under the packages folder (e.g. 'lib/foo.dart'
222 // will be emitted at out/packages/package_name/foo.dart). 223 // will be emitted at out/packages/package_name/foo.dart).
223 filepath = path.join(outPackages, id.package, 224 filepath = path.join(outPackages, id.package,
224 _toSystemPath(id.path.substring(4))); 225 _toSystemPath(id.path.substring(4)));
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 * of every file that was not transformed by barback. 267 * of every file that was not transformed by barback.
267 */ 268 */
268 Future _emitPackagesDir(BarbackOptions options) { 269 Future _emitPackagesDir(BarbackOptions options) {
269 if (options.transformPolymerDependencies) return new Future.value(null); 270 if (options.transformPolymerDependencies) return new Future.value(null);
270 var outPackages = path.join(options.outDir, 'packages'); 271 var outPackages = path.join(options.outDir, 'packages');
271 _ensureDir(outPackages); 272 _ensureDir(outPackages);
272 273
273 // Copy all the files we didn't process 274 // Copy all the files we didn't process
274 var dirs = options.packageDirs; 275 var dirs = options.packageDirs;
275 276
276 return Future.forEach(_polymerPackageDependencies, (package) { 277 return forEachPooledFuture(_polymerPackageDependencies, (package) {
277 return Future.forEach(_listPackageDir(package, 'lib', options), (relpath) { 278 return forEachPooledFuture(_listPackageDir(package, 'lib', options), (relpat h) {
278 var inpath = path.join(dirs[package], relpath); 279 var inpath = path.join(dirs[package], relpath);
279 var outpath = path.join(outPackages, package, relpath.substring(4)); 280 var outpath = path.join(outPackages, package, relpath.substring(4));
280 return _copyFile(inpath, outpath); 281 return _copyFile(inpath, outpath);
281 }); 282 });
282 }); 283 });
283 } 284 }
284 285
285 /** Ensure [dirpath] exists. */ 286 /** Ensure [dirpath] exists. */
286 void _ensureDir(String dirpath) { 287 void _ensureDir(String dirpath) {
287 new Directory(dirpath).createSync(recursive: true); 288 new Directory(dirpath).createSync(recursive: true);
(...skipping 13 matching lines...) Expand all
301 Future _copyFile(String inpath, String outpath) { 302 Future _copyFile(String inpath, String outpath) {
302 _ensureDir(path.dirname(outpath)); 303 _ensureDir(path.dirname(outpath));
303 return new File(inpath).openRead().pipe(new File(outpath).openWrite()); 304 return new File(inpath).openRead().pipe(new File(outpath).openWrite());
304 } 305 }
305 306
306 /** Write contents of an [asset] into a file at [filepath]. */ 307 /** Write contents of an [asset] into a file at [filepath]. */
307 Future _writeAsset(String filepath, Asset asset) { 308 Future _writeAsset(String filepath, Asset asset) {
308 _ensureDir(path.dirname(filepath)); 309 _ensureDir(path.dirname(filepath));
309 return asset.read().pipe(new File(filepath).openWrite()); 310 return asset.read().pipe(new File(filepath).openWrite());
310 } 311 }
OLDNEW
« no previous file with comments | « pkg/barback/lib/src/utils.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698