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

Unified Diff: tests/isolate/mandel_isolate_stream_test.dart

Issue 12919011: Remove streamSpawnUri and mangler. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/isolate/isolate_complex_messages_stream_test.dart ('k') | tests/isolate/message_stream2_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/isolate/mandel_isolate_stream_test.dart
diff --git a/tests/isolate/mandel_isolate_test.dart b/tests/isolate/mandel_isolate_stream_test.dart
similarity index 83%
copy from tests/isolate/mandel_isolate_test.dart
copy to tests/isolate/mandel_isolate_stream_test.dart
index 3e0354475fe5385c5cf0454cb5be1a830343a0f4..302696e58b5326967003f96fde43cb34731d3d54 100644
--- a/tests/isolate/mandel_isolate_test.dart
+++ b/tests/isolate/mandel_isolate_stream_test.dart
@@ -86,22 +86,29 @@ class MandelbrotState {
class LineProcessorClient {
LineProcessorClient(MandelbrotState this._state, int this._id) {
- _port = spawnFunction(processLines);
+ _sink = streamSpawnFunction(processLines);
+ _box = new MessageBox();
+ _sink.add(_box.sink);
+ _box.stream.listen((List<int> message) {
+ _state.notifyProcessedLine(this, _currentLine, message);
+ });
}
void processLine(int y) {
- _port.call(y).then((List<int> message) {
- _state.notifyProcessedLine(this, y, message);
- });
+ _currentLine = y;
+ _sink.add(y);
}
void shutdown() {
- _port.send(TERMINATION_MESSAGE, null);
+ _sink.close();
+ _box.stream.close();
}
MandelbrotState _state;
int _id;
- SendPort _port;
+ IsolateSink _sink;
+ int _currentLine;
+ MessageBox _box;
}
List<int> processLine(int y) {
@@ -132,12 +139,15 @@ List<int> processLine(int y) {
}
void processLines() {
- port.receive((message, SendPort replyTo) {
- if (message == TERMINATION_MESSAGE) {
- assert(replyTo == null);
- port.close();
- } else {
- replyTo.send(processLine(message), null);
+ bool isFirst = true;
+ IsolateSink replyTo;
+
+ stream.listen((message) {
+ if (isFirst) {
+ isFirst = false;
+ replyTo = message;
+ return;
}
+ replyTo.add(processLine(message));
});
}
« no previous file with comments | « tests/isolate/isolate_complex_messages_stream_test.dart ('k') | tests/isolate/message_stream2_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698