| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library dart.pkg.isolate.sample.httpserver; | 5 library isolate.example.http_server; |
| 6 | 6 |
| 7 import "dart:async"; |
| 7 import "dart:io"; | 8 import "dart:io"; |
| 8 import "dart:async"; | |
| 9 import "dart:isolate"; | 9 import "dart:isolate"; |
| 10 import "package:isolate/isolaterunner.dart"; | 10 |
| 11 import 'package:isolate/isolate_runner.dart'; |
| 12 import "package:isolate/ports.dart"; |
| 11 import "package:isolate/runner.dart"; | 13 import "package:isolate/runner.dart"; |
| 12 import "package:isolate/ports.dart"; | |
| 13 | 14 |
| 14 typedef Future RemoteStop(); | 15 typedef Future RemoteStop(); |
| 15 | 16 |
| 16 Future<RemoteStop> runHttpServer( | 17 Future<RemoteStop> runHttpServer( |
| 17 Runner runner, ServerSocket socket, HttpListener listener) { | 18 Runner runner, ServerSocket socket, HttpListener listener) { |
| 18 return runner.run(_startHttpServer, new List(2)..[0] = socket.reference | 19 return runner.run(_startHttpServer, new List(2)..[0] = socket.reference |
| 19 ..[1] = listener) | 20 ..[1] = listener) |
| 20 .then((SendPort stopPort) => () => _sendStop(stopPort)); | 21 .then((SendPort stopPort) => () => _sendStop(stopPort)); |
| 21 } | 22 } |
| 22 | 23 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 stoppers.forEach((f) => f()); | 107 stoppers.forEach((f) => f()); |
| 107 counter.close(); | 108 counter.close(); |
| 108 } | 109 } |
| 109 }; | 110 }; |
| 110 print("Server listening on port $port for 25 requests"); | 111 print("Server listening on port $port for 25 requests"); |
| 111 print("Test with:"); | 112 print("Test with:"); |
| 112 print(" ab -c10 -n 25 http://localhost:$port/"); | 113 print(" ab -c10 -n 25 http://localhost:$port/"); |
| 113 }); | 114 }); |
| 114 }); | 115 }); |
| 115 } | 116 } |
| OLD | NEW |