| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 " echo('Running isolateMain');\n" | 64 " echo('Running isolateMain');\n" |
| 65 " receivePort.receive((message, SendPort replyTo) {\n" | 65 " receivePort.receive((message, SendPort replyTo) {\n" |
| 66 " echo('Received: ' + message);\n" | 66 " echo('Received: ' + message);\n" |
| 67 " replyTo.send((message + 1), null);\n" | 67 " replyTo.send((message + 1), null);\n" |
| 68 " });\n" | 68 " });\n" |
| 69 "}\n" | 69 "}\n" |
| 70 "\n" | 70 "\n" |
| 71 "main() {\n" | 71 "main() {\n" |
| 72 " var isolate = new CustomIsolate(\"isolateMain\");\n" | 72 " var isolate = new CustomIsolate(\"isolateMain\");\n" |
| 73 " isolate.spawn().then((SendPort port) {\n" | 73 " isolate.spawn().then((SendPort port) {\n" |
| 74 " port.call(42).receive((message, replyTo) {\n" | 74 " port.call(42).then((message) {\n" |
| 75 " echo('Received: ' + message);\n" | 75 " echo('Received: ' + message);\n" |
| 76 " });\n" | 76 " });\n" |
| 77 " });\n" | 77 " });\n" |
| 78 " return 'success';\n" | 78 " return 'success';\n" |
| 79 "}\n"; | 79 "}\n"; |
| 80 | 80 |
| 81 | 81 |
| 82 // An entry in our event queue. | 82 // An entry in our event queue. |
| 83 class Event { | 83 class Event { |
| 84 protected: | 84 protected: |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 OS::Print("-- Finished event loop --\n"); | 357 OS::Print("-- Finished event loop --\n"); |
| 358 EXPECT_STREQ("Received: 43", saved_echo); | 358 EXPECT_STREQ("Received: 43", saved_echo); |
| 359 free(const_cast<char*>(saved_echo)); | 359 free(const_cast<char*>(saved_echo)); |
| 360 | 360 |
| 361 delete event_queue; | 361 delete event_queue; |
| 362 } | 362 } |
| 363 | 363 |
| 364 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). | 364 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). |
| 365 | 365 |
| 366 } // namespace dart | 366 } // namespace dart |
| OLD | NEW |