| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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).receive((message, replyTo) {\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: |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 OS::Print("-- Finished event loop --\n"); | 345 OS::Print("-- Finished event loop --\n"); |
| 346 EXPECT_STREQ("Received: 43", saved_echo); | 346 EXPECT_STREQ("Received: 43", saved_echo); |
| 347 free(const_cast<char*>(saved_echo)); | 347 free(const_cast<char*>(saved_echo)); |
| 348 | 348 |
| 349 delete event_queue; | 349 delete event_queue; |
| 350 } | 350 } |
| 351 | 351 |
| 352 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). | 352 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). |
| 353 | 353 |
| 354 } // namespace dart | 354 } // namespace dart |
| OLD | NEW |