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

Side by Side Diff: sdk/lib/io/file_impl.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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/bin/stdio_patch.dart ('k') | sdk/lib/io/stdio.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 part of dart.io; 5 part of dart.io;
6 6
7 // Read the file in blocks of size 64k. 7 // Read the file in blocks of size 64k.
8 const int _BLOCK_SIZE = 64 * 1024; 8 const int _BLOCK_SIZE = 64 * 1024;
9 9
10 10
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 174
175 class _FileStreamConsumer extends StreamConsumer<List<int>> { 175 class _FileStreamConsumer extends StreamConsumer<List<int>> {
176 File _file; 176 File _file;
177 Future<RandomAccessFile> _openFuture; 177 Future<RandomAccessFile> _openFuture;
178 StreamSubscription _subscription; 178 StreamSubscription _subscription;
179 179
180 _FileStreamConsumer(File this._file, FileMode mode) { 180 _FileStreamConsumer(File this._file, FileMode mode) {
181 _openFuture = _file.open(mode: mode); 181 _openFuture = _file.open(mode: mode);
182 } 182 }
183 183
184 _FileStreamConsumer.fromStdio(int fd) {
185 assert(1 <= fd && fd <= 2);
186 _openFuture = new Future.value(_File._openStdioSync(fd));
187 }
188
189 Future<File> addStream(Stream<List<int>> stream) { 184 Future<File> addStream(Stream<List<int>> stream) {
190 Completer<File> completer = new Completer<File>(); 185 Completer<File> completer = new Completer<File>();
191 _openFuture 186 _openFuture
192 .then((openedFile) { 187 .then((openedFile) {
193 void error(e, [StackTrace stackTrace]) { 188 void error(e, [StackTrace stackTrace]) {
194 _subscription.cancel(); 189 _subscription.cancel();
195 openedFile.close(); 190 openedFile.close();
196 completer.completeError(e, stackTrace); 191 completer.completeError(e, stackTrace);
197 } 192 }
198 _subscription = stream.listen( 193 _subscription = stream.listen(
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after
906 901
907 void _checkAvailable() { 902 void _checkAvailable() {
908 if (_asyncDispatched) { 903 if (_asyncDispatched) {
909 throw new FileSystemException("An async operation is currently pending", p ath); 904 throw new FileSystemException("An async operation is currently pending", p ath);
910 } 905 }
911 if (closed) { 906 if (closed) {
912 throw new FileSystemException("File closed", path); 907 throw new FileSystemException("File closed", path);
913 } 908 }
914 } 909 }
915 } 910 }
OLDNEW
« no previous file with comments | « runtime/bin/stdio_patch.dart ('k') | sdk/lib/io/stdio.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698