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

Side by Side Diff: pkg/barback/lib/src/utils/file_pool.dart

Issue 399963004: Move pub/barback's Pool class into its own package. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 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
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 library barback.utils.file_pool; 5 library barback.utils.file_pool;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:convert'; 8 import 'dart:convert';
9 import 'dart:io'; 9 import 'dart:io';
10 10
11 import 'package:pool/pool.dart';
Bob Nystrom 2014/07/17 22:09:14 How about giving this a bit more specific name. Ma
nweiz 2014/07/17 22:56:55 I can if you want, but I think in a programming co
Bob Nystrom 2014/07/21 17:47:36 Maybe it's just my background, but I'd actually ex
11 import 'package:stack_trace/stack_trace.dart'; 12 import 'package:stack_trace/stack_trace.dart';
12 13
13 import '../utils.dart'; 14 import '../utils.dart';
14 import 'pool.dart';
15 15
16 /// Manages a pool of files that are opened for reading to cope with maximum 16 /// Manages a pool of files that are opened for reading to cope with maximum
17 /// file descriptor limits. 17 /// file descriptor limits.
18 /// 18 ///
19 /// If a file cannot be opened because too many files are already open, this 19 /// If a file cannot be opened because too many files are already open, this
20 /// will defer the open until a previously opened file is closed and then try 20 /// will defer the open until a previously opened file is closed and then try
21 /// again. If this doesn't succeed after a certain amount of time, the open 21 /// again. If this doesn't succeed after a certain amount of time, the open
22 /// will fail and the original "too many files" exception will be thrown. 22 /// will fail and the original "too many files" exception will be thrown.
23 class FilePool { 23 class FilePool {
24 /// The underlying pool. 24 /// The underlying pool.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 var completer = new Completer<List<int>>(); 57 var completer = new Completer<List<int>>();
58 var builder = new BytesBuilder(); 58 var builder = new BytesBuilder();
59 59
60 openRead(path).listen(builder.add, onDone: () { 60 openRead(path).listen(builder.add, onDone: () {
61 completer.complete(builder.takeBytes()); 61 completer.complete(builder.takeBytes());
62 }, onError: completer.completeError, cancelOnError: true); 62 }, onError: completer.completeError, cancelOnError: true);
63 63
64 return completer.future; 64 return completer.future;
65 } 65 }
66 } 66 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698