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

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

Issue 27242002: Use file pool to handle running out of file descriptors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revise to work with readAsString() too. (Thanks Kevin!) 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/barback/lib/src/file_pool.dart » ('j') | pkg/barback/lib/src/file_pool.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/barback/lib/src/asset.dart
diff --git a/pkg/barback/lib/src/asset.dart b/pkg/barback/lib/src/asset.dart
index 254edfbdf9577ea0f067f1dbdc9beae6d5d78d8f..fda813380dc1965b6b901db7e043f531256eed41 100644
--- a/pkg/barback/lib/src/asset.dart
+++ b/pkg/barback/lib/src/asset.dart
@@ -9,6 +9,7 @@ import 'dart:convert';
import 'dart:io';
import 'asset_id.dart';
+import 'file_pool.dart';
import 'stream_replayer.dart';
import 'utils.dart';
@@ -99,16 +100,20 @@ class _BinaryAsset extends Asset {
/// An asset backed by a file on the local file system.
class _FileAsset extends Asset {
+ /// Use a [FilePool] to handle reads so we can try to cope with running out
+ /// of file descriptors more gracefully.
+ static final _pool = new FilePool();
+
final File _file;
nweiz 2013/10/16 00:16:01 I don't understand why we're storing a File object
Bob Nystrom 2013/10/16 00:51:46 FileAsset already has the File object, so this was
_FileAsset(AssetId id, this._file)
: super(id);
Future<String> readAsString({Encoding encoding}) {
if (encoding == null) encoding = UTF8;
- return _file.readAsString(encoding: encoding);
+ return _pool.readAsString(_file, encoding);
}
- Stream<List<int>> read() => _file.openRead();
+ Stream<List<int>> read() => _pool.openRead(_file);
String toString() => 'File "${_file.path}"';
}
« no previous file with comments | « no previous file | pkg/barback/lib/src/file_pool.dart » ('j') | pkg/barback/lib/src/file_pool.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698