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

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

Issue 13680002: StreamConsumer has an addStream and a close functions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update comments. Created 7 years, 8 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/http_parser.dart ('k') | tests/lib/async/slow_consumer2_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/io_sink.dart
diff --git a/sdk/lib/io/io_sink.dart b/sdk/lib/io/io_sink.dart
index 71426da8f678ad427ff403e791961412241dfe97..4ee7b4fbb63b123ee3cba197f821e69e467ec973 100644
--- a/sdk/lib/io/io_sink.dart
+++ b/sdk/lib/io/io_sink.dart
@@ -37,14 +37,23 @@ abstract class IOSink<T> implements StreamConsumer<List<int>, T>, StringSink {
Future<T> consume(Stream<List<int>> stream);
/**
+ * Adds all elements of the given [stream] to `this`.
+ */
+ Future<T> addStream(Stream<List<int>> stream);
+
+ /**
* Like [consume], but will not close the target when done.
+ *
+ * *Deprecated*: use [addStream] instead.
*/
Future<T> writeStream(Stream<List<int>> stream);
/**
* Close the target.
*/
- void close();
+ // TODO(floitsch): Currently the future cannot be typed because it has
+ // hardcoded type Future<HttpClientResponse> in subclass HttpClientRequest.
+ Future close();
/**
* Get future that will complete when all data has been written to
@@ -134,17 +143,22 @@ class _IOSinkImpl<T> implements IOSink<T> {
}
Future<T> writeStream(Stream<List<int>> stream) {
+ return addStream(stream);
+ }
+
+ Future<T> addStream(Stream<List<int>> stream) {
if (_isBound) {
throw new StateError("IOSink is already bound to a stream");
}
return _fillFromStream(stream, unbind: true);
}
- void close() {
+ Future close() {
if (_isBound) {
throw new StateError("IOSink is already bound to a stream");
}
_controller.close();
+ return _pipeFuture;
}
Future<T> get done {
« no previous file with comments | « sdk/lib/io/http_parser.dart ('k') | tests/lib/async/slow_consumer2_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698