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

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

Issue 301193010: Update documentation for "close". (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add tests. Don't throw if listening on broadcast stream after close. Created 6 years, 6 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 // Controller for creating and adding events to a stream. 8 // Controller for creating and adding events to a stream.
9 // ------------------------------------------------------------------- 9 // -------------------------------------------------------------------
10 10
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 401
402 /** 402 /**
403 * Send or enqueue an error event. 403 * Send or enqueue an error event.
404 */ 404 */
405 void addError(Object error, [StackTrace stackTrace]) { 405 void addError(Object error, [StackTrace stackTrace]) {
406 if (!_mayAddEvent) throw _badEventState(); 406 if (!_mayAddEvent) throw _badEventState();
407 _addError(error, stackTrace); 407 _addError(error, stackTrace);
408 } 408 }
409 409
410 /** 410 /**
411 * Closes this controller. 411 * Closes this controller and sends a done event on the stream.
412 * 412 *
413 * After closing, no further events may be added using [add] or [addError]. 413 * After closing, no further events may be added using [add] or [addError].
414 * 414 *
415 * You are allowed to close the controller more than once, but only the first 415 * You are allowed to close the controller more than once, but only the first
416 * call has any effect. 416 * call has any effect.
417 * 417 *
418 * The first time a controller is closed, a "done" event is sent to its 418 * The first time a controller is closed, a "done" event is added to its
419 * stream. 419 * stream.
420 *
421 * The returned future is completed when the done event has been delivered.
420 */ 422 */
421 Future close() { 423 Future close() {
422 if (isClosed) { 424 if (isClosed) {
423 return _ensureDoneFuture(); 425 return _ensureDoneFuture();
424 } 426 }
425 if (!_mayAddEvent) throw _badEventState(); 427 if (!_mayAddEvent) throw _badEventState();
426 _state |= _STATE_CLOSED; 428 _state |= _STATE_CLOSED;
427 if (hasListener) { 429 if (hasListener) {
428 _sendDone(); 430 _sendDone();
429 } else if (_isInitialState) { 431 } else if (_isInitialState) {
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 _StreamControllerAddStreamState(_StreamController controller, 761 _StreamControllerAddStreamState(_StreamController controller,
760 this.varData, 762 this.varData,
761 Stream source, 763 Stream source,
762 bool cancelOnError) 764 bool cancelOnError)
763 : super(controller, source, cancelOnError) { 765 : super(controller, source, cancelOnError) {
764 if (controller.isPaused) { 766 if (controller.isPaused) {
765 addSubscription.pause(); 767 addSubscription.pause();
766 } 768 }
767 } 769 }
768 } 770 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698