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

Unified Diff: pkg/barback/lib/src/file_pool.dart

Issue 55983005: Serialize barback assets more efficiently. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 7 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/barback/lib/src/asset.dart ('k') | pkg/barback/lib/src/internal_asset.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/barback/lib/src/file_pool.dart
diff --git a/pkg/barback/lib/src/file_pool.dart b/pkg/barback/lib/src/file_pool.dart
index b8dcc6a59e704d716054544dcef237f322c59658..31d32ed04582b9e9b8cc5acb23cb19477c9ea555 100644
--- a/pkg/barback/lib/src/file_pool.dart
+++ b/pkg/barback/lib/src/file_pool.dart
@@ -26,36 +26,36 @@ class FilePool {
/// substantial additional throughput.
final Pool _pool = new Pool(32, timeout: new Duration(seconds: 60));
- /// Opens [file] for reading.
+ /// Opens the file at [path] for reading.
///
/// When the returned stream is listened to, if there are too many files
/// open, this will wait for a previously opened file to be closed and then
/// try again.
- Stream<List<int>> openRead(File file) {
+ Stream<List<int>> openRead(String path) {
return futureStream(_pool.request().then((resource) {
- return file.openRead().transform(new StreamTransformer.fromHandlers(
- handleDone: (sink) {
+ return new File(path).openRead().transform(
+ new StreamTransformer.fromHandlers(handleDone: (sink) {
sink.close();
resource.release();
}));
}));
}
- /// Reads [file] as a string using [encoding].
+ /// Reads [path] as a string using [encoding].
///
/// If there are too many files open and the read fails, this will wait for
/// a previously opened file to be closed and then try again.
- Future<String> readAsString(File file, Encoding encoding) {
- return _readAsBytes(file).then(encoding.decode);
+ Future<String> readAsString(String path, Encoding encoding) {
+ return _readAsBytes(path).then(encoding.decode);
}
- /// Reads [file] as a list of bytes, using [openRead] to retry if there are
+ /// Reads [path] as a list of bytes, using [openRead] to retry if there are
/// failures.
- Future<List<int>> _readAsBytes(File file) {
+ Future<List<int>> _readAsBytes(String path) {
var completer = new Completer<List<int>>();
var builder = new BytesBuilder();
- openRead(file).listen(builder.add, onDone: () {
+ openRead(path).listen(builder.add, onDone: () {
completer.complete(builder.takeBytes());
}, onError: completer.completeError, cancelOnError: true);
« no previous file with comments | « pkg/barback/lib/src/asset.dart ('k') | pkg/barback/lib/src/internal_asset.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698