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

Side by Side Diff: tests/lib/async/slow_consumer2_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_consumer2_test; 7 library slow_consumer2_test;
8 8
9 import "package:expect/expect.dart"; 9 import "package:expect/expect.dart";
10 import 'dart:async'; 10 import 'dart:async';
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 64
65 class DataProvider { 65 class DataProvider {
66 final int chunkSize; 66 final int chunkSize;
67 final int bytesPerSecond; 67 final int bytesPerSecond;
68 int sentCount = 0; 68 int sentCount = 0;
69 int targetCount; 69 int targetCount;
70 StreamController controller; 70 StreamController controller;
71 71
72 DataProvider(int this.bytesPerSecond, int this.targetCount, this.chunkSize) { 72 DataProvider(int this.bytesPerSecond, int this.targetCount, this.chunkSize) {
73 controller = new StreamController( 73 controller = new StreamController(
74 sync: true,
74 onPause: onPauseStateChange, 75 onPause: onPauseStateChange,
75 onResume: onPauseStateChange); 76 onResume: onPauseStateChange);
76 Timer.run(send); 77 Timer.run(send);
77 } 78 }
78 79
79 Stream get stream => controller.stream; 80 Stream get stream => controller.stream;
80 81
81 send() { 82 send() {
82 if (controller.isPaused) return; 83 if (controller.isPaused) return;
83 if (sentCount == targetCount) { 84 if (sentCount == targetCount) {
(...skipping 30 matching lines...) Expand all
114 // file). If the consumer doesn't pause the data-provider it will run out of 115 // file). If the consumer doesn't pause the data-provider it will run out of
115 // heap-space. 116 // heap-space.
116 117
117 new DataProvider(800 * MB, 100 * MB, 1 * MB).stream 118 new DataProvider(800 * MB, 100 * MB, 1 * MB).stream
118 .pipe(new SlowConsumer(200 * MB, 5 * MB)) 119 .pipe(new SlowConsumer(200 * MB, 5 * MB))
119 .then((count) { 120 .then((count) {
120 port.close(); 121 port.close();
121 Expect.equals(100 * MB, count); 122 Expect.equals(100 * MB, count);
122 }); 123 });
123 } 124 }
OLDNEW
« no previous file with comments | « sdk/lib/web_audio/dartium/web_audio_dartium.dart ('k') | tests/lib/async/slow_consumer_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698