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

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: 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 61
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(sync: true,
floitsch 2013/05/30 12:13:48 next line.
Lasse Reichstein Nielsen 2013/05/31 05:51:59 Done.
72 onPause: onPauseStateChange, 72 onPause: onPauseStateChange,
73 onResume: onPauseStateChange); 73 onResume: onPauseStateChange);
74 Timer.run(send); 74 Timer.run(send);
75 } 75 }
76 76
77 Stream get stream => controller.stream; 77 Stream get stream => controller.stream;
78 78
79 send() { 79 send() {
80 if (pendingSend != null) { 80 if (pendingSend != null) {
81 pendingSend.cancel(); 81 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 117 // file). If the consumer doesn't pause the data-provider it will run out of
118 // heap-space. 118 // heap-space.
119 119
120 new DataProvider(800 * MB, 100 * MB, 1 * MB).stream 120 new DataProvider(800 * MB, 100 * MB, 1 * MB).stream
121 .pipe(new SlowConsumer(200 * MB)) 121 .pipe(new SlowConsumer(200 * MB))
122 .then((count) { 122 .then((count) {
123 port.close(); 123 port.close();
124 Expect.equals(100 * MB, count); 124 Expect.equals(100 * MB, count);
125 }); 125 });
126 } 126 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698