| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 #include "include/dart_api.h" | 5 #include "include/dart_api.h" |
| 6 | 6 |
| 7 #include "vm/unit_test.h" | 7 #include "vm/unit_test.h" |
| 8 | 8 |
| 9 // Custom Isolate Test. | 9 // Custom Isolate Test. |
| 10 // | 10 // |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 "\n" | 50 "\n" |
| 51 "interface CustomIsolate default CustomIsolateImpl {\n" | 51 "interface CustomIsolate default CustomIsolateImpl {\n" |
| 52 " CustomIsolate(String entry);\n" | 52 " CustomIsolate(String entry);\n" |
| 53 "\n" | 53 "\n" |
| 54 " Future<SendPort> spawn();\n" | 54 " Future<SendPort> spawn();\n" |
| 55 "}\n" | 55 "}\n" |
| 56 "\n" | 56 "\n" |
| 57 "isolateMain() {\n" | 57 "isolateMain() {\n" |
| 58 " echo('Running isolateMain');\n" | 58 " echo('Running isolateMain');\n" |
| 59 " mainPort.receive((message, SendPort replyTo) {\n" | 59 " mainPort.receive((message, SendPort replyTo) {\n" |
| 60 " echo('Received: ' + message);\n" | 60 " echo('Received: $message');\n" |
| 61 " replyTo.send((message + 1), null);\n" | 61 " replyTo.send((message + 1), null);\n" |
| 62 " });\n" | 62 " });\n" |
| 63 "}\n" | 63 "}\n" |
| 64 "\n" | 64 "\n" |
| 65 "main() {\n" | 65 "main() {\n" |
| 66 " var isolate = new CustomIsolate(\"isolateMain\");\n" | 66 " var isolate = new CustomIsolate(\"isolateMain\");\n" |
| 67 " isolate.spawn().then((SendPort port) {\n" | 67 " isolate.spawn().then((SendPort port) {\n" |
| 68 " port.call(42).then((message) {\n" | 68 " port.call(42).then((message) {\n" |
| 69 " echo('Received: ' + message);\n" | 69 " echo('Received: $message');\n" |
| 70 " });\n" | 70 " });\n" |
| 71 " });\n" | 71 " });\n" |
| 72 " return 'success';\n" | 72 " return 'success';\n" |
| 73 "}\n"; | 73 "}\n"; |
| 74 | 74 |
| 75 | 75 |
| 76 // An entry in our event queue. | 76 // An entry in our event queue. |
| 77 class Event { | 77 class Event { |
| 78 protected: | 78 protected: |
| 79 explicit Event(Dart_Isolate isolate) : isolate_(isolate), next_(NULL) {} | 79 explicit Event(Dart_Isolate isolate) : isolate_(isolate), next_(NULL) {} |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 OS::Print("-- Finished event loop --\n"); | 337 OS::Print("-- Finished event loop --\n"); |
| 338 EXPECT_STREQ("Received: 43", saved_echo); | 338 EXPECT_STREQ("Received: 43", saved_echo); |
| 339 free(const_cast<char*>(saved_echo)); | 339 free(const_cast<char*>(saved_echo)); |
| 340 | 340 |
| 341 delete event_queue; | 341 delete event_queue; |
| 342 } | 342 } |
| 343 | 343 |
| 344 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). | 344 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). |
| 345 | 345 |
| 346 } // namespace dart | 346 } // namespace dart |
| OLD | NEW |