| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 "\n" | 59 "\n" |
| 60 "isolateMain() {\n" | 60 "isolateMain() {\n" |
| 61 " echo('Running isolateMain');\n" | 61 " echo('Running isolateMain');\n" |
| 62 " receivePort.receive((message, SendPort replyTo) {\n" | 62 " receivePort.receive((message, SendPort replyTo) {\n" |
| 63 " echo('Received: ' + message);\n" | 63 " echo('Received: ' + message);\n" |
| 64 " replyTo.send((message + 1), null);\n" | 64 " replyTo.send((message + 1), null);\n" |
| 65 " });\n" | 65 " });\n" |
| 66 "}\n" | 66 "}\n" |
| 67 "\n" | 67 "\n" |
| 68 "main() {\n" | 68 "main() {\n" |
| 69 " Isolate isolate = new CustomIsolate(\"isolateMain\");\n" | 69 " var isolate = new CustomIsolate(\"isolateMain\");\n" |
| 70 " isolate.spawn().then((SendPort port) {\n" | 70 " isolate.spawn().then((SendPort port) {\n" |
| 71 " port.call(42).receive((message, replyTo) {\n" | 71 " port.call(42).receive((message, replyTo) {\n" |
| 72 " echo('Received: ' + message);\n" | 72 " echo('Received: ' + message);\n" |
| 73 " });\n" | 73 " });\n" |
| 74 " });\n" | 74 " });\n" |
| 75 " return 'success';\n" | 75 " return 'success';\n" |
| 76 "}\n"; | 76 "}\n"; |
| 77 | 77 |
| 78 | 78 |
| 79 // An entry in our event queue. | 79 // An entry in our event queue. |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 OS::Print("-- Finished event loop --\n"); | 418 OS::Print("-- Finished event loop --\n"); |
| 419 EXPECT_STREQ("Received: 43", saved_echo); | 419 EXPECT_STREQ("Received: 43", saved_echo); |
| 420 free(const_cast<char*>(saved_echo)); | 420 free(const_cast<char*>(saved_echo)); |
| 421 | 421 |
| 422 delete event_queue; | 422 delete event_queue; |
| 423 } | 423 } |
| 424 | 424 |
| 425 #endif // TARGET_ARCH_IA32. | 425 #endif // TARGET_ARCH_IA32. |
| 426 | 426 |
| 427 } // namespace dart | 427 } // namespace dart |
| OLD | NEW |