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

Unified Diff: tests/standalone/io/socket_many_connections_test.dart

Issue 27215002: Very simple version of Isolates. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 7 years, 2 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/standalone/io/socket_close_test.dart ('k') | tests/standalone/io/testing_server.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/socket_many_connections_test.dart
diff --git a/tests/standalone/io/socket_many_connections_test.dart b/tests/standalone/io/socket_many_connections_test.dart
index bda8031d8fd8e70907d95a7bdacb5dc47e6cb272..d6ddcbdb05751419aa54dfee40ea52459073a07f 100644
--- a/tests/standalone/io/socket_many_connections_test.dart
+++ b/tests/standalone/io/socket_many_connections_test.dart
@@ -6,6 +6,7 @@
library ServerTest;
import "package:expect/expect.dart";
+import "package:async_helper/async_helper.dart";
import "dart:async";
import "dart:io";
import "dart:isolate";
@@ -16,11 +17,8 @@ const CONNECTIONS = 200;
class SocketManyConnectionsTest {
SocketManyConnectionsTest.start()
- : _receivePort = new ReceivePort(),
- _sendPort = null,
- _connections = 0,
+ : _connections = 0,
_sockets = new List<Socket>(CONNECTIONS) {
- _sendPort = spawnFunction(startTestServer);
initialize();
}
@@ -46,29 +44,32 @@ class SocketManyConnectionsTest {
}
void initialize() {
- _receivePort.receive((var message, SendPort replyTo) {
- _port = message;
+ var receivePort = new ReceivePort();
+ var remote = Isolate.spawn(startTestServer, receivePort.sendPort);
+ receivePort.first.then((msg) {
+ this._port = msg[0];
+ this._closeSendPort = msg[1];
run();
});
- _sendPort.send(TestingServer.INIT, _receivePort.toSendPort());
}
void close() {
- _sendPort.send(TestingServer.SHUTDOWN, _receivePort.toSendPort());
- _receivePort.close();
+ _closeSendPort.send(null);
+ asyncEnd();
}
int _port;
- ReceivePort _receivePort;
- SendPort _sendPort;
+ SendPort _closeSendPort;
List<Socket> _sockets;
int _connections;
}
-void startTestServer() {
+void startTestServer(SendPort replyPort) {
var server = new TestServer();
- port.receive(server.dispatch);
+ server.init().then((port) {
+ replyPort.send([port, server.closeSendPort]);
+ });
}
class TestServer extends TestingServer {
@@ -99,5 +100,6 @@ class TestServer extends TestingServer {
}
main() {
+ asyncStart();
SocketManyConnectionsTest test = new SocketManyConnectionsTest.start();
}
« no previous file with comments | « tests/standalone/io/socket_close_test.dart ('k') | tests/standalone/io/testing_server.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698