OLD | NEW |
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 /** Abstract and private interface for a place to put events. */ | 7 /** Abstract and private interface for a place to put events. */ |
8 abstract class _EventSink<T> { | 8 abstract class _EventSink<T> { |
9 void _add(T data); | 9 void _add(T data); |
10 void _addError(Object error, StackTrace stackTrace); | 10 void _addError(Object error, StackTrace stackTrace); |
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 // Send one event per call to moveNext. | 525 // Send one event per call to moveNext. |
526 // If moveNext returns true, send the current element as data. | 526 // If moveNext returns true, send the current element as data. |
527 // If moveNext returns false, send a done event and clear the _iterator. | 527 // If moveNext returns false, send a done event and clear the _iterator. |
528 // If moveNext throws an error, send an error and clear the _iterator. | 528 // If moveNext throws an error, send an error and clear the _iterator. |
529 // After an error, no further events will be sent. | 529 // After an error, no further events will be sent. |
530 bool isDone; | 530 bool isDone; |
531 try { | 531 try { |
532 isDone = !_iterator.moveNext(); | 532 isDone = !_iterator.moveNext(); |
533 } catch (e, s) { | 533 } catch (e, s) { |
534 _iterator = null; | 534 _iterator = null; |
535 dispatch._sendError(_asyncError(e, s), s); | 535 dispatch._sendError(e, s); |
536 return; | 536 return; |
537 } | 537 } |
538 if (!isDone) { | 538 if (!isDone) { |
539 dispatch._sendData(_iterator.current); | 539 dispatch._sendData(_iterator.current); |
540 } else { | 540 } else { |
541 _iterator = null; | 541 _iterator = null; |
542 dispatch._sendDone(); | 542 dispatch._sendDone(); |
543 } | 543 } |
544 } | 544 } |
545 | 545 |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1028 _Future<bool> hasNext = _futureOrPrefetch; | 1028 _Future<bool> hasNext = _futureOrPrefetch; |
1029 _clear(); | 1029 _clear(); |
1030 hasNext._complete(false); | 1030 hasNext._complete(false); |
1031 return; | 1031 return; |
1032 } | 1032 } |
1033 _subscription.pause(); | 1033 _subscription.pause(); |
1034 _futureOrPrefetch = null; | 1034 _futureOrPrefetch = null; |
1035 _state = _STATE_EXTRA_DONE; | 1035 _state = _STATE_EXTRA_DONE; |
1036 } | 1036 } |
1037 } | 1037 } |
OLD | NEW |