| 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.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 Loading... |
| 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; |
| OLD | NEW |