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

Side by Side Diff: tests/lib/async/slow_consumer_test.dart

Issue 16125005: Make new StreamController be async by default. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments Created 7 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 // VMOptions=--old_gen_heap_size=64 5 // VMOptions=--old_gen_heap_size=64
6 6
7 library slow_consumer_test; 7 library slow_consumer_test;
8 8
9 import "package:expect/expect.dart"; 9 import "package:expect/expect.dart";
10 import 'dart:async'; 10 import 'dart:async';
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 class DataProvider { 62 class DataProvider {
63 final int chunkSize; 63 final int chunkSize;
64 final int bytesPerSecond; 64 final int bytesPerSecond;
65 int sentCount = 0; 65 int sentCount = 0;
66 int targetCount; 66 int targetCount;
67 StreamController controller; 67 StreamController controller;
68 Timer pendingSend; 68 Timer pendingSend;
69 69
70 DataProvider(int this.bytesPerSecond, int this.targetCount, this.chunkSize) { 70 DataProvider(int this.bytesPerSecond, int this.targetCount, this.chunkSize) {
71 controller = new StreamController( 71 controller = new StreamController(
72 sync: true,
72 onPause: onPauseStateChange, 73 onPause: onPauseStateChange,
73 onResume: onPauseStateChange); 74 onResume: onPauseStateChange);
74 Timer.run(send); 75 Timer.run(send);
75 } 76 }
76 77
77 Stream get stream => controller.stream; 78 Stream get stream => controller.stream;
78 79
79 send() { 80 send() {
80 if (pendingSend != null) { 81 if (pendingSend != null) {
81 pendingSend.cancel(); 82 pendingSend.cancel();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 // file). If the consumer doesn't pause the data-provider it will run out of 118 // file). If the consumer doesn't pause the data-provider it will run out of
118 // heap-space. 119 // heap-space.
119 120
120 new DataProvider(800 * MB, 100 * MB, 1 * MB).stream 121 new DataProvider(800 * MB, 100 * MB, 1 * MB).stream
121 .pipe(new SlowConsumer(200 * MB)) 122 .pipe(new SlowConsumer(200 * MB))
122 .then((count) { 123 .then((count) {
123 port.close(); 124 port.close();
124 Expect.equals(100 * MB, count); 125 Expect.equals(100 * MB, count);
125 }); 126 });
126 } 127 }
OLDNEW
« no previous file with comments | « tests/lib/async/slow_consumer2_test.dart ('k') | tests/lib/async/stream_controller_async_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698