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 import 'dart:io'; |
9 | 9 |
10 /// A pair of values. | 10 /// A pair of values. |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 stream.listen( | 189 stream.listen( |
190 controller.add, | 190 controller.add, |
191 onError: controller.addError, | 191 onError: controller.addError, |
192 onDone: controller.close); | 192 onDone: controller.close); |
193 }).catchError((e, stackTrace) { | 193 }).catchError((e, stackTrace) { |
194 controller.addError(e, stackTrace); | 194 controller.addError(e, stackTrace); |
195 controller.close(); | 195 controller.close(); |
196 }); | 196 }); |
197 return controller.stream; | 197 return controller.stream; |
198 } | 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 |