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

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

Issue 28733009: Make sure barback's FilePool doesn't take up *all* the available FDs. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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
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; 5 library barback.utils;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io';
8 9
9 /// A pair of values. 10 /// A pair of values.
10 class Pair<E, F> { 11 class Pair<E, F> {
11 E first; 12 E first;
12 F last; 13 F last;
13 14
14 Pair(this.first, this.last); 15 Pair(this.first, this.last);
15 16
16 String toString() => '($first, $last)'; 17 String toString() => '($first, $last)';
17 18
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 stream.listen( 189 stream.listen(
189 controller.add, 190 controller.add,
190 onError: controller.addError, 191 onError: controller.addError,
191 onDone: controller.close); 192 onDone: controller.close);
192 }).catchError((e, stackTrace) { 193 }).catchError((e, stackTrace) {
193 controller.addError(e, stackTrace); 194 controller.addError(e, stackTrace);
194 controller.close(); 195 controller.close();
195 }); 196 });
196 return controller.stream; 197 return controller.stream;
197 } 198 }
199
200 // TODO(nweiz): Use a built-in function when issue 14244 is fixed.
201 int get maxFileDescriptors {
202 if (_maxFileDescriptors != null) return _maxFileDescriptors;
203
204 // Running "sh -c ulimit -n" via the command line always reports "unlimited",
205 // even when that's clearly false. Instead we fall back on OS-based
206 // heuristics.
207 if (Platform.isWindows) {
208 _maxFileDescriptors = 512;
209 return _maxFileDescriptors;
210 } else if (Platform.isMacOS) {
211 _maxFileDescriptors = 16348;
212 return _maxFileDescriptors;
213 } else {
214 _maxFileDescriptors = 256;
215 return _maxFileDescriptors;
216 }
217 }
218 int _maxFileDescriptors;
OLDNEW
« pkg/barback/lib/src/file_pool.dart ('K') | « pkg/barback/lib/src/file_pool.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698