| 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 // |
| 11 // This mid-size test uses the Dart Embedding Api to create a custom | 11 // This mid-size test uses the Dart Embedding Api to create a custom |
| 12 // isolate abstraction. Instead of having a dedicated thread for each | 12 // isolate abstraction. Instead of having a dedicated thread for each |
| 13 // isolate, as is the case normally, this implementation shares a | 13 // isolate, as is the case normally, this implementation shares a |
| 14 // single thread among the isolates using an event queue. | 14 // single thread among the isolates using an event queue. |
| 15 | 15 |
| 16 namespace dart { | 16 namespace dart { |
| 17 | 17 |
| 18 // Only ia32, x64, and arm can run execution tests. | |
| 19 #if defined(TARGET_ARCH_IA32) || \ | |
| 20 defined(TARGET_ARCH_X64) || \ | |
| 21 defined(TARGET_ARCH_ARM) | |
| 22 | |
| 23 static void native_echo(Dart_NativeArguments args); | 18 static void native_echo(Dart_NativeArguments args); |
| 24 static void CustomIsolateImpl_start(Dart_NativeArguments args); | 19 static void CustomIsolateImpl_start(Dart_NativeArguments args); |
| 25 static Dart_NativeFunction NativeLookup(Dart_Handle name, int argc); | 20 static Dart_NativeFunction NativeLookup(Dart_Handle name, int argc); |
| 26 | 21 |
| 27 | 22 |
| 28 static const char* kCustomIsolateScriptChars = | 23 static const char* kCustomIsolateScriptChars = |
| 29 "import 'dart:async';\n" | 24 "import 'dart:async';\n" |
| 30 "import 'dart:isolate';\n" | 25 "import 'dart:isolate';\n" |
| 31 "\n" | 26 "\n" |
| 32 "ReceivePort mainPort;\n" | 27 "ReceivePort mainPort;\n" |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 delete event; | 332 delete event; |
| 338 event = event_queue->Get(); | 333 event = event_queue->Get(); |
| 339 } | 334 } |
| 340 OS::Print("-- Finished event loop --\n"); | 335 OS::Print("-- Finished event loop --\n"); |
| 341 EXPECT_STREQ("Received: 43", saved_echo); | 336 EXPECT_STREQ("Received: 43", saved_echo); |
| 342 free(const_cast<char*>(saved_echo)); | 337 free(const_cast<char*>(saved_echo)); |
| 343 | 338 |
| 344 delete event_queue; | 339 delete event_queue; |
| 345 } | 340 } |
| 346 | 341 |
| 347 #endif // TARGET_ARCH_IA32 || TARGET_ARCH_X64 || TARGET_ARCH_ARM | |
| 348 | |
| 349 } // namespace dart | 342 } // namespace dart |
| OLD | NEW |