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

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

Issue 14196003: Change StreamController constructor. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments and rebase. Created 7 years, 8 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
« no previous file with comments | « tests/lib/async/slow_consumer2_test.dart ('k') | tests/lib/async/stream_state_helper.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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(onPauseStateChange: onPauseStateChange); 71 controller = new StreamController(
72 onPause: onPauseStateChange,
73 onResume: onPauseStateChange);
72 Timer.run(send); 74 Timer.run(send);
73 } 75 }
74 76
75 Stream get stream => controller.stream; 77 Stream get stream => controller.stream;
76 78
77 send() { 79 send() {
78 if (pendingSend != null) { 80 if (pendingSend != null) {
79 pendingSend.cancel(); 81 pendingSend.cancel();
80 pendingSend = null; 82 pendingSend = null;
81 } 83 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 // 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
116 // heap-space. 118 // heap-space.
117 119
118 new DataProvider(800 * MB, 100 * MB, 1 * MB).stream 120 new DataProvider(800 * MB, 100 * MB, 1 * MB).stream
119 .pipe(new SlowConsumer(200 * MB)) 121 .pipe(new SlowConsumer(200 * MB))
120 .then((count) { 122 .then((count) {
121 port.close(); 123 port.close();
122 Expect.equals(100 * MB, count); 124 Expect.equals(100 * MB, count);
123 }); 125 });
124 } 126 }
OLDNEW
« no previous file with comments | « tests/lib/async/slow_consumer2_test.dart ('k') | tests/lib/async/stream_state_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698