| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 // TODO(nweiz): Get rid of this when https://codereview.chromium.org/1241723003/ | 5 // TODO(nweiz): Get rid of this when https://codereview.chromium.org/1241723003/ |
| 6 // lands. | 6 // lands. |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 | 9 |
| 10 import "package:async/async.dart" hide ForkableStream, StreamQueue; | 10 import "package:async/async.dart" hide ForkableStream, StreamQueue; |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 Future<T> get future => _completer.future; | 433 Future<T> get future => _completer.future; |
| 434 | 434 |
| 435 bool addEvents(Queue<Result> events) { | 435 bool addEvents(Queue<Result> events) { |
| 436 if (events.isEmpty) return false; | 436 if (events.isEmpty) return false; |
| 437 events.removeFirst().complete(_completer); | 437 events.removeFirst().complete(_completer); |
| 438 return true; | 438 return true; |
| 439 } | 439 } |
| 440 | 440 |
| 441 void close(Queue<Result> events) { | 441 void close(Queue<Result> events) { |
| 442 var errorFuture = | 442 var errorFuture = |
| 443 new Future.sync(() => throw new StateError("No elements")); | 443 new Future<T>.sync(() => throw new StateError("No elements")); |
| 444 _completer.complete(errorFuture); | 444 _completer.complete(errorFuture); |
| 445 } | 445 } |
| 446 } | 446 } |
| 447 | 447 |
| 448 /// Request for a [StreamQueue.skip] call. | 448 /// Request for a [StreamQueue.skip] call. |
| 449 class _SkipRequest implements _EventRequest { | 449 class _SkipRequest implements _EventRequest { |
| 450 /// Completer for the future returned by the skip call. | 450 /// Completer for the future returned by the skip call. |
| 451 final _completer = new Completer<int>(); | 451 final _completer = new Completer<int>(); |
| 452 | 452 |
| 453 /// Number of remaining events to skip. | 453 /// Number of remaining events to skip. |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 688 event.addTo(controller); | 688 event.addTo(controller); |
| 689 } | 689 } |
| 690 | 690 |
| 691 var fork = _streamQueue._sourceStream.fork(); | 691 var fork = _streamQueue._sourceStream.fork(); |
| 692 controller.addStream(fork, cancelOnError: false) | 692 controller.addStream(fork, cancelOnError: false) |
| 693 .whenComplete(controller.close); | 693 .whenComplete(controller.close); |
| 694 _completer.setSourceStream(controller.stream); | 694 _completer.setSourceStream(controller.stream); |
| 695 } | 695 } |
| 696 } | 696 } |
| 697 } | 697 } |
| OLD | NEW |