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

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

Issue 12393009: Change and structure how Stream implementations do callbacks. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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
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
11 /** 11 /**
12 * A source of asynchronous data events. 12 * A source of asynchronous data events.
13 * 13 *
14 * A Stream provides a sequence of events. Each event is either a data event or 14 * A Stream provides a sequence of events. Each event is either a data event or
15 * an error event, representing the result of a single computation. When the 15 * an error event, representing the result of a single computation. When the
16 * Stream is exhausted, it may send a single "done" event. 16 * Stream is exhausted, it may send a single "done" event.
17 * 17 *
18 * You can [listen] on a stream to receive the events it sends. When you listen, 18 * You can [listen] on a stream to receive the events it sends. When you listen,
19 * you receive a [StreamSubscription] object that can be used to stop listening, 19 * you receive a [StreamSubscription] object that can be used to stop listening,
20 * or to temporarily pause events from the stream. 20 * or to temporarily pause events from the stream.
21 * 21 *
22 * When an event is fired, the listeners at that time are informed. 22 * When an event is fired, the listeners at that time are informed.
23 * If a listener is added or removed while an event is being fired, the change 23 * If a listener is added while an event is being fired, the change
24 * will only take effect after the event is completely fired. 24 * will only take effect after the event is completely fired. If a listener
25 * is canceled, it immediately stops receiveing events.
floitsch 2013/03/01 21:52:30 receiving
Lasse Reichstein Nielsen 2013/03/04 11:53:02 Done.
26 *
27 * When the "done" event is fired, subscribers are unsubscribed before
28 * receiving the event. After the event has been sent, the stream has no
29 * subscribers. Adding new subscribers after this point is allowed, but
30 * they will just receive a new "done" event as soon as possible.
25 * 31 *
26 * Streams always respect "pause" requests. If necessary they need to buffer 32 * Streams always respect "pause" requests. If necessary they need to buffer
27 * their input, but often, and preferably, they can simply request their input 33 * their input, but often, and preferably, they can simply request their input
28 * to pause too. 34 * to pause too.
29 * 35 *
30 * There are two kinds of streams: The normal "single-subscription" streams and 36 * There are two kinds of streams: The normal "single-subscription" streams and
31 * "broadcast" streams. 37 * "broadcast" streams.
32 * 38 *
33 * A single-subscription stream allows only a single listener at a time. 39 * A single-subscription stream allows only a single listener at a time.
34 * It holds back events until it gets a listener, and it may exhaust 40 * It holds back events until it gets a listener, and it may exhaust
(...skipping 1071 matching lines...) Expand 10 before | Expand all | Expand 10 after
1106 } 1112 }
1107 1113
1108 class _StreamOutputSinkWrapper<T> implements StreamSink<T> { 1114 class _StreamOutputSinkWrapper<T> implements StreamSink<T> {
1109 _StreamOutputSink _sink; 1115 _StreamOutputSink _sink;
1110 _StreamOutputSinkWrapper(this._sink); 1116 _StreamOutputSinkWrapper(this._sink);
1111 1117
1112 void add(T data) => _sink._sendData(data); 1118 void add(T data) => _sink._sendData(data);
1113 void signalError(AsyncError error) => _sink._sendError(error); 1119 void signalError(AsyncError error) => _sink._sendError(error);
1114 void close() => _sink._sendDone(); 1120 void close() => _sink._sendDone();
1115 } 1121 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698