| OLD | NEW |
| 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 library barback.file_pool; | 5 library barback.file_pool; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | |
| 9 import 'dart:convert'; | 8 import 'dart:convert'; |
| 10 import 'dart:io'; | 9 import 'dart:io'; |
| 11 | 10 |
| 12 import 'pool.dart'; | 11 import 'pool.dart'; |
| 13 import 'utils.dart'; | 12 import 'utils.dart'; |
| 14 | 13 |
| 15 /// Manages a pool of files that are opened for reading to cope with maximum | 14 /// Manages a pool of files that are opened for reading to cope with maximum |
| 16 /// file descriptor limits. | 15 /// file descriptor limits. |
| 17 /// | 16 /// |
| 18 /// If a file cannot be opened because too many files are already open, this | 17 /// If a file cannot be opened because too many files are already open, this |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 var completer = new Completer<List<int>>(); | 55 var completer = new Completer<List<int>>(); |
| 57 var builder = new BytesBuilder(); | 56 var builder = new BytesBuilder(); |
| 58 | 57 |
| 59 openRead(file).listen(builder.add, onDone: () { | 58 openRead(file).listen(builder.add, onDone: () { |
| 60 completer.complete(builder.takeBytes()); | 59 completer.complete(builder.takeBytes()); |
| 61 }, onError: completer.completeError, cancelOnError: true); | 60 }, onError: completer.completeError, cancelOnError: true); |
| 62 | 61 |
| 63 return completer.future; | 62 return completer.future; |
| 64 } | 63 } |
| 65 } | 64 } |
| OLD | NEW |