| 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 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 // Send one event per call to moveNext. | 522 // Send one event per call to moveNext. |
| 523 // If moveNext returns true, send the current element as data. | 523 // If moveNext returns true, send the current element as data. |
| 524 // If moveNext returns false, send a done event and clear the _iterator. | 524 // If moveNext returns false, send a done event and clear the _iterator. |
| 525 // If moveNext throws an error, send an error and clear the _iterator. | 525 // If moveNext throws an error, send an error and clear the _iterator. |
| 526 // After an error, no further events will be sent. | 526 // After an error, no further events will be sent. |
| 527 bool isDone; | 527 bool isDone; |
| 528 try { | 528 try { |
| 529 isDone = !_iterator.moveNext(); | 529 isDone = !_iterator.moveNext(); |
| 530 } catch (e, s) { | 530 } catch (e, s) { |
| 531 _iterator = null; | 531 _iterator = null; |
| 532 dispatch._sendError(_asyncError(e, s), s); | 532 dispatch._sendError(e, s); |
| 533 return; | 533 return; |
| 534 } | 534 } |
| 535 if (!isDone) { | 535 if (!isDone) { |
| 536 dispatch._sendData(_iterator.current); | 536 dispatch._sendData(_iterator.current); |
| 537 } else { | 537 } else { |
| 538 _iterator = null; | 538 _iterator = null; |
| 539 dispatch._sendDone(); | 539 dispatch._sendDone(); |
| 540 } | 540 } |
| 541 } | 541 } |
| 542 | 542 |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1025 _Future<bool> hasNext = _futureOrPrefetch; | 1025 _Future<bool> hasNext = _futureOrPrefetch; |
| 1026 _clear(); | 1026 _clear(); |
| 1027 hasNext._complete(false); | 1027 hasNext._complete(false); |
| 1028 return; | 1028 return; |
| 1029 } | 1029 } |
| 1030 _subscription.pause(); | 1030 _subscription.pause(); |
| 1031 _futureOrPrefetch = null; | 1031 _futureOrPrefetch = null; |
| 1032 _state = _STATE_EXTRA_DONE; | 1032 _state = _STATE_EXTRA_DONE; |
| 1033 } | 1033 } |
| 1034 } | 1034 } |
| OLD | NEW |