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

Side by Side Diff: sdk/lib/async/stream.dart

Issue 2149893002: Make StreamIterator not delay pausing between requests. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « no previous file | sdk/lib/async/stream_impl.dart » ('j') | sdk/lib/async/stream_impl.dart » ('J')
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.async; 5 part of dart.async;
6 6
7 // ------------------------------------------------------------------- 7 // -------------------------------------------------------------------
8 // Core Stream types 8 // Core Stream types
9 // ------------------------------------------------------------------- 9 // -------------------------------------------------------------------
10 10
(...skipping 1745 matching lines...) Expand 10 before | Expand all | Expand 10 after
1756 * This wraps a [Stream] and a subscription on the stream. It listens 1756 * This wraps a [Stream] and a subscription on the stream. It listens
1757 * on the stream, and completes the future returned by [moveNext] when the 1757 * on the stream, and completes the future returned by [moveNext] when the
1758 * next value becomes available. 1758 * next value becomes available.
1759 */ 1759 */
1760 abstract class StreamIterator<T> { 1760 abstract class StreamIterator<T> {
1761 1761
1762 /** Create a [StreamIterator] on [stream]. */ 1762 /** Create a [StreamIterator] on [stream]. */
1763 factory StreamIterator(Stream<T> stream) 1763 factory StreamIterator(Stream<T> stream)
1764 // TODO(lrn): use redirecting factory constructor when type 1764 // TODO(lrn): use redirecting factory constructor when type
1765 // arguments are supported. 1765 // arguments are supported.
1766 => new _StreamIteratorImpl<T>(stream); 1766 => new _StreamIterator<T>(stream);
1767 1767
1768 /** 1768 /**
1769 * Wait for the next stream value to be available. 1769 * Wait for the next stream value to be available.
1770 * 1770 *
1771 * Returns a future which will complete with either `true` or `false`. 1771 * Returns a future which will complete with either `true` or `false`.
1772 * Completing with `true` means that another event has been received and 1772 * Completing with `true` means that another event has been received and
1773 * can be read as [current]. 1773 * can be read as [current].
1774 * Completing with `false` means that the stream itearation is done and 1774 * Completing with `false` means that the stream itearation is done and
1775 * no further events will ever be available. 1775 * no further events will ever be available.
1776 * The future may complete with an error, if the stream produces an error, 1776 * The future may complete with an error, if the stream produces an error,
(...skipping 21 matching lines...) Expand all
1798 /** 1798 /**
1799 * Cancels the stream iterator (and the underlying stream subscription) early. 1799 * Cancels the stream iterator (and the underlying stream subscription) early.
1800 * 1800 *
1801 * The stream iterator is automatically canceled if the [moveNext] future 1801 * The stream iterator is automatically canceled if the [moveNext] future
1802 * completes with either `false` or an error. 1802 * completes with either `false` or an error.
1803 * 1803 *
1804 * If you need to stop listening for values before the stream iterator is 1804 * If you need to stop listening for values before the stream iterator is
1805 * automatically closed, you must call [cancel] to ensure that the stream 1805 * automatically closed, you must call [cancel] to ensure that the stream
1806 * is properly closed. 1806 * is properly closed.
1807 * 1807 *
1808 * If [moveNext] has been called when the iterator is cancelled, 1808 * If [moveNext] has been called when the iterator is canceled,
1809 * its returned future will complete with `false` as value, 1809 * its returned future will complete with `false` as value,
1810 * as will all further calls to [moveNext]. 1810 * as will all further calls to [moveNext].
1811 * 1811 *
1812 * Returns a future if the cancel-operation is not completed synchronously. 1812 * Returns a future if the cancel-operation is not completed synchronously.
1813 * Otherwise returns `null`. 1813 * Otherwise returns `null`.
1814 */ 1814 */
1815 Future cancel(); 1815 Future cancel();
1816 } 1816 }
1817 1817
1818 1818
1819 /** 1819 /**
1820 * Wraps an [_EventSink] so it exposes only the [EventSink] interface. 1820 * Wraps an [_EventSink] so it exposes only the [EventSink] interface.
1821 */ 1821 */
1822 class _ControllerEventSinkWrapper<T> implements EventSink<T> { 1822 class _ControllerEventSinkWrapper<T> implements EventSink<T> {
1823 EventSink _sink; 1823 EventSink _sink;
1824 _ControllerEventSinkWrapper(this._sink); 1824 _ControllerEventSinkWrapper(this._sink);
1825 1825
1826 void add(T data) { _sink.add(data); } 1826 void add(T data) { _sink.add(data); }
1827 void addError(error, [StackTrace stackTrace]) { 1827 void addError(error, [StackTrace stackTrace]) {
1828 _sink.addError(error, stackTrace); 1828 _sink.addError(error, stackTrace);
1829 } 1829 }
1830 void close() { _sink.close(); } 1830 void close() { _sink.close(); }
1831 } 1831 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/async/stream_impl.dart » ('j') | sdk/lib/async/stream_impl.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698