| OLD | NEW |
| 1 // Copyright (c) 2012, 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 * Concepts used here: | 6 * Concepts used here: |
| 7 * | 7 * |
| 8 * "manager" - A manager contains one or more isolates, schedules their | 8 * "manager" - A manager contains one or more isolates, schedules their |
| 9 * execution, and performs other plumbing on their behalf. The isolate | 9 * execution, and performs other plumbing on their behalf. The isolate |
| 10 * present at the creation of the manager is designated as its "root isolate". | 10 * present at the creation of the manager is designated as its "root isolate". |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 initGlobals(); | 164 initGlobals(); |
| 165 } | 165 } |
| 166 | 166 |
| 167 // these are filled lazily the first time the isolate starts running. | 167 // these are filled lazily the first time the isolate starts running. |
| 168 void initGlobals() native @'$initGlobals(this);'; | 168 void initGlobals() native @'$initGlobals(this);'; |
| 169 | 169 |
| 170 /** | 170 /** |
| 171 * Run [code] in the context of the isolate represented by [this]. Note this | 171 * Run [code] in the context of the isolate represented by [this]. Note this |
| 172 * is called from JavaScript (see $wrap_call in corejs.dart). | 172 * is called from JavaScript (see $wrap_call in corejs.dart). |
| 173 */ | 173 */ |
| 174 void eval(Function code) { | 174 Dynamic eval(Function code) { |
| 175 var old = _globalState.currentContext; | 175 var old = _globalState.currentContext; |
| 176 _globalState.currentContext = this; | 176 _globalState.currentContext = this; |
| 177 this._setGlobals(); | 177 this._setGlobals(); |
| 178 var result = null; | 178 var result = null; |
| 179 try { | 179 try { |
| 180 result = code(); | 180 result = code(); |
| 181 } finally { | 181 } finally { |
| 182 _globalState.currentContext = old; | 182 _globalState.currentContext = old; |
| 183 if (old != null) old._setGlobals(); | 183 if (old != null) old._setGlobals(); |
| 184 } | 184 } |
| (...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 'command': 'start2', | 675 'command': 'start2', |
| 676 'id': workerId, | 676 'id': workerId, |
| 677 // Note: we serialize replyPort twice because the child worker needs to | 677 // Note: we serialize replyPort twice because the child worker needs to |
| 678 // first deserialize the worker id, before it can correctly deserialize | 678 // first deserialize the worker id, before it can correctly deserialize |
| 679 // the port (port deserialization is sensitive to what is the current | 679 // the port (port deserialization is sensitive to what is the current |
| 680 // workerId). | 680 // workerId). |
| 681 'replyTo': _serializeMessage(replyPort), | 681 'replyTo': _serializeMessage(replyPort), |
| 682 'functionName': functionName })); | 682 'functionName': functionName })); |
| 683 } | 683 } |
| 684 } | 684 } |
| OLD | NEW |