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

Unified Diff: sdk/lib/io/stdio.dart

Issue 195893012: Use a sync-writing StreamConsumer for stdout/stderr. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sdk/lib/io/file_impl.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/stdio.dart
diff --git a/sdk/lib/io/stdio.dart b/sdk/lib/io/stdio.dart
index 5b5e62f539c7b0a669d7760ca83769441ac4ed4c..9c034f437adbca9db958341dea7552cd361eaf79 100644
--- a/sdk/lib/io/stdio.dart
+++ b/sdk/lib/io/stdio.dart
@@ -202,6 +202,36 @@ class StdoutException implements IOException {
}
+class _StdConsumer implements StreamConsumer<List<int>> {
+ final _file;
+
+ _StdConsumer(int fd) : _file = _File._openStdioSync(fd);
+
+ Future addStream(Stream<List<int>> stream) {
+ var completer = new Completer();
+ var sub;
+ sub = stream.listen(
+ (data) {
+ try {
+ _file.writeFromSync(data);
+ } catch (e, s) {
+ sub.cancel();
+ completer.completeError(e, s);
+ }
+ },
+ onError: completer.completeError,
+ onDone: completer.complete,
+ cancelOnError: true);
+ return completer.future;
+ }
+
+ Future close() {
+ _file.closeSync();
+ return new Future.value();
+ }
+}
+
+
class _StdSink implements IOSink {
final IOSink _sink;
« no previous file with comments | « sdk/lib/io/file_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698