| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | |
| 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. | |
| 4 | |
| 5 | |
| 6 /** | |
| 7 * The `dart:isolate` library defines APIs to spawn and communicate with | |
| 8 * isolates. | |
| 9 * | |
| 10 * All code in dart runs in the context of an isolate. Each isolate has its own | |
| 11 * heap, which means that all values in memory, including globals, are available | |
| 12 * only to that isolate. The only mechanism available to communicate between | |
| 13 * isolates is to pass messages. Messages are sent through ports. This library | |
| 14 * defines [ReceivePort] to represent the receiver's end of a communication | |
| 15 * channel, and [SendPort] to represent the sender's end. | |
| 16 * | |
| 17 * All isolates start with an initial receive port, which is set in the | |
| 18 * top-level property [port]. This port is used to establish the first | |
| 19 * communication between isolates. | |
| 20 * | |
| 21 * Two APIs are available to spawn a new isolate: [spawnFunction] and | |
| 22 * [spawnUri]. [spawnFunction] creates a new isolate that is using the same | |
| 23 * source code as the current isolate, [spawnUri] allows spawning an isolate | |
| 24 * that was written independently. | |
| 25 * | |
| 26 * There is currently no way to indicate in the API whether the isolates should | |
| 27 * run on the same or different threads. The underlying system will schedule the | |
| 28 * isolate were appropriate. In the near future we will add an API to create DOM | |
| 29 * isolates. These are isolates that share access to the DOM. All DOM isolates | |
| 30 * will run on the UI thread. | |
| 31 * | |
| 32 * This library is still evolving. New APIs are being added, and some will be | |
| 33 * deprecated and removed. In particular, the class [Isolate] will be | |
| 34 * deprecated as soon the dartvm has an implementation working for | |
| 35 * [spawnFunction] and [spawnUri], and we have an API to spawn DOM isolates. | |
| 36 */ | |
| 37 #library("dart:isolate"); | |
| 38 | |
| 39 #import("dart:uri"); | |
| 40 #source("isolate_api.dart"); | |
| 41 #source("timer.dart"); | |
| 42 #source("timer_hook.dart"); | |
| 43 #source("serialization.dart"); | |
| 44 #source("dart2js/compiler_hooks.dart"); | |
| 45 #source("dart2js/isolateimpl.dart"); | |
| 46 #source("dart2js/messages.dart"); | |
| 47 #source("dart2js/ports.dart"); | |
| 48 #source("dart2js/timer_provider.dart"); | |
| 49 | |
| 50 /** | |
| 51 * Called by the compiler to support switching | |
| 52 * between isolates when we get a callback from the DOM. | |
| 53 */ | |
| 54 void _callInIsolate(_IsolateContext isolate, Function function) { | |
| 55 isolate.eval(function); | |
| 56 _globalState.topEventLoop.run(); | |
| 57 } | |
| 58 | |
| 59 /** | |
| 60 * Called by the compiler to fetch the current isolate context. | |
| 61 */ | |
| 62 void _currentIsolate() => _globalState.currentContext; | |
| OLD | NEW |