Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 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 | 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 | 5 |
| 6 // Dart isolate's API and implementation for frog. Since dartdocs are generated | |
| 7 // using frog, we include here some additional library level comments. | |
| 8 | |
| 9 /** | 6 /** |
| 10 * The `dart:isolate` library defines APIs to spawn and communicate with | 7 * The `dart:isolate` library defines APIs to spawn and communicate with |
| 11 * isolates. | 8 * isolates. |
| 12 * | 9 * |
| 13 * All code in dart runs in the context of an isolate. Each isolate has its own | 10 * All code in dart runs in the context of an isolate. Each isolate has its own |
| 14 * heap, which means that all values in memory, including globals, are available | 11 * heap, which means that all values in memory, including globals, are available |
| 15 * only to that isolate. The only mechanism available to communicate between | 12 * only to that isolate. The only mechanism available to communicate between |
| 16 * isolates is to pass messages. Messages are sent through ports. This library | 13 * isolates is to pass messages. Messages are sent through ports. This library |
| 17 * defines [ReceivePort] to represent the receiver's end of a communication | 14 * defines [ReceivePort] to represent the receiver's end of a communication |
| 18 * channel, and [SendPort] to represent the sender's end. | 15 * channel, and [SendPort] to represent the sender's end. |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 38 * [spawnFunction] and [spawnUri], and we have an API to spawn DOM isolates. | 35 * [spawnFunction] and [spawnUri], and we have an API to spawn DOM isolates. |
| 39 */ | 36 */ |
| 40 #library("dart:isolate"); | 37 #library("dart:isolate"); |
| 41 | 38 |
| 42 #import("../uri/uri.dart"); | 39 #import("../uri/uri.dart"); |
| 43 #source("isolate_api.dart"); | 40 #source("isolate_api.dart"); |
| 44 #source("frog/compiler_hooks.dart"); | 41 #source("frog/compiler_hooks.dart"); |
| 45 #source("frog/isolateimpl.dart"); | 42 #source("frog/isolateimpl.dart"); |
| 46 #source("frog/ports.dart"); | 43 #source("frog/ports.dart"); |
| 47 #source("frog/messages.dart"); | 44 #source("frog/messages.dart"); |
| 48 #native("frog/natives.js"); | |
|
ngeoffray
2012/03/11 15:43:54
I had to create another file because leg does not
| |
| 49 | |
| 50 ReceivePort _port; | |
| 51 | |
| 52 SendPort _spawnFunction(void topLevelFunction()) { | |
| 53 final name = _IsolateNatives._getJSFunctionName(topLevelFunction); | |
| 54 if (name == null) { | |
| 55 throw new UnsupportedOperationException( | |
| 56 "only top-level functions can be spawned."); | |
| 57 } | |
| 58 return _IsolateNatives._spawn2(name, null, false); | |
| 59 } | |
| 60 | |
| 61 SendPort _spawnUri(String uri) { | |
| 62 return _IsolateNatives._spawn2(null, uri, false); | |
| 63 } | |
| OLD | NEW |