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

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

Issue 12328104: Change new List(n) to return fixed length list. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merge to head. Created 7 years, 9 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=32 5 // VMOptions=--old_gen_heap_size=32
6 6
7 library slow_consumer2_test; 7 library slow_consumer2_test;
8 8
9 import 'dart:async'; 9 import 'dart:async';
10 import 'dart:isolate'; 10 import 'dart:isolate';
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 if (sentCount == targetCount) { 68 if (sentCount == targetCount) {
69 controller.close(); 69 controller.close();
70 return; 70 return;
71 } 71 }
72 int listSize = chunkSize; 72 int listSize = chunkSize;
73 sentCount += listSize; 73 sentCount += listSize;
74 if (sentCount > targetCount) { 74 if (sentCount > targetCount) {
75 listSize -= sentCount - targetCount; 75 listSize -= sentCount - targetCount;
76 sentCount = targetCount; 76 sentCount = targetCount;
77 } 77 }
78 controller.add(new List.fixedLength(listSize)); 78 controller.add(new List(listSize));
79 int ms = listSize * 1000 ~/ bytesPerSecond; 79 int ms = listSize * 1000 ~/ bytesPerSecond;
80 Duration duration = new Duration(milliseconds: ms); 80 Duration duration = new Duration(milliseconds: ms);
81 if (!controller.isPaused) new Timer(duration, send); 81 if (!controller.isPaused) new Timer(duration, send);
82 } 82 }
83 83
84 onPauseStateChange() { 84 onPauseStateChange() {
85 // We don't care if we just unpaused or paused. In either case we just 85 // We don't care if we just unpaused or paused. In either case we just
86 // call send which will test it for us. 86 // call send which will test it for us.
87 send(); 87 send();
88 } 88 }
(...skipping 10 matching lines...) Expand all
99 // file). If the consumer doesn't pause the data-provider it will run out of 99 // file). If the consumer doesn't pause the data-provider it will run out of
100 // heap-space. 100 // heap-space.
101 101
102 new DataProvider(800 * MB, 100 * MB, 1 * MB).stream 102 new DataProvider(800 * MB, 100 * MB, 1 * MB).stream
103 .pipe(new SlowConsumer(200 * MB, 5 * MB)) 103 .pipe(new SlowConsumer(200 * MB, 5 * MB))
104 .then((count) { 104 .then((count) {
105 port.close(); 105 port.close();
106 Expect.equals(100 * MB, count); 106 Expect.equals(100 * MB, count);
107 }); 107 });
108 } 108 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698