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 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 get id() => 0; | 322 get id() => 0; |
323 void set id(int i) { throw new NotImplementedException(); } | 323 void set id(int i) { throw new NotImplementedException(); } |
324 void set onmessage(f) { | 324 void set onmessage(f) { |
325 throw new Exception("onmessage should not be set on MainManagerStub"); | 325 throw new Exception("onmessage should not be set on MainManagerStub"); |
326 } | 326 } |
327 void postMessage(msg) native @"$globalThis.postMessage(msg);"; | 327 void postMessage(msg) native @"$globalThis.postMessage(msg);"; |
328 void terminate() {} // Nothing useful to do here. | 328 void terminate() {} // Nothing useful to do here. |
329 } | 329 } |
330 | 330 |
331 /** | 331 /** |
332 * A stub for interacting with a manager built on a web worker. The type | 332 * A stub for interacting with a manager built on a web worker. The |
333 * Worker is also defined in 'dart:dom', but we define it here to avoid | 333 * type Worker is also defined in 'dart:dom_deprecated', but we define |
334 * introducing a dependency from corelib to dom. This definition uses a | 334 * it here to avoid introducing a dependency from corelib to dom. This |
335 * 'hidden' type (* prefix on the native name) to enforce that the type is | 335 * definition uses a 'hidden' type (* prefix on the native name) to |
336 * defined dynamically only when web workers are actually available. | 336 * enforce that the type is defined dynamically only when web workers |
| 337 * are actually available. |
337 */ | 338 */ |
338 class _WorkerStub implements _ManagerStub native "*Worker" { | 339 class _WorkerStub implements _ManagerStub native "*Worker" { |
339 get id() native "return this.id;"; | 340 get id() native "return this.id;"; |
340 void set id(i) native "this.id = i;"; | 341 void set id(i) native "this.id = i;"; |
341 void set onmessage(f) native "this.onmessage = f;"; | 342 void set onmessage(f) native "this.onmessage = f;"; |
342 void postMessage(msg) native "return this.postMessage(msg);"; | 343 void postMessage(msg) native "return this.postMessage(msg);"; |
343 // terminate() is implemented by Worker. | 344 // terminate() is implemented by Worker. |
344 abstract void terminate(); | 345 abstract void terminate(); |
345 } | 346 } |
346 | 347 |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 'command': 'start2', | 648 'command': 'start2', |
648 'id': workerId, | 649 'id': workerId, |
649 // Note: we serialize replyPort twice because the child worker needs to | 650 // Note: we serialize replyPort twice because the child worker needs to |
650 // first deserialize the worker id, before it can correctly deserialize | 651 // first deserialize the worker id, before it can correctly deserialize |
651 // the port (port deserialization is sensitive to what is the current | 652 // the port (port deserialization is sensitive to what is the current |
652 // workerId). | 653 // workerId). |
653 'replyTo': _serializeMessage(replyPort), | 654 'replyTo': _serializeMessage(replyPort), |
654 'functionName': functionName })); | 655 'functionName': functionName })); |
655 } | 656 } |
656 } | 657 } |
OLD | NEW |