Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1276)

Side by Side Diff: lib/isolate/frog/isolateimpl.dart

Issue 10536118: Create an initial port. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rename __port to _lazy_port Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/co19/co19-leg.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 20 matching lines...) Expand all
31 // Running any Dart code outside the context of an isolate gives it 31 // Running any Dart code outside the context of an isolate gives it
32 // the change to break the isolate abstraction. 32 // the change to break the isolate abstraction.
33 _Manager get _globalState() native "return \$globalState;"; 33 _Manager get _globalState() native "return \$globalState;";
34 set _globalState(_Manager val) native "\$globalState = val;"; 34 set _globalState(_Manager val) native "\$globalState = val;";
35 35
36 void _fillStatics(context) native @""" 36 void _fillStatics(context) native @"""
37 $globals = context.isolateStatics; 37 $globals = context.isolateStatics;
38 $static_init(); 38 $static_init();
39 """; 39 """;
40 40
41 ReceivePort _port; 41 ReceivePort _lazy_port;
42 ReceivePort get _port() {
43 if (_lazy_port === null) {
44 _lazy_port = new ReceivePort();
45 }
46 return _lazy_port;
47 }
42 48
43 SendPort _spawnFunction(void topLevelFunction()) { 49 SendPort _spawnFunction(void topLevelFunction()) {
44 final name = _IsolateNatives._getJSFunctionName(topLevelFunction); 50 final name = _IsolateNatives._getJSFunctionName(topLevelFunction);
45 if (name == null) { 51 if (name == null) {
46 throw new UnsupportedOperationException( 52 throw new UnsupportedOperationException(
47 "only top-level functions can be spawned."); 53 "only top-level functions can be spawned.");
48 } 54 }
49 return _IsolateNatives._spawn2(name, null, false); 55 return _IsolateNatives._spawn2(name, null, false);
50 } 56 }
51 57
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 if (uri != null) throw new UnsupportedOperationException( 598 if (uri != null) throw new UnsupportedOperationException(
593 "Currently spawnUri is not supported without web workers."); 599 "Currently spawnUri is not supported without web workers.");
594 _globalState.topEventLoop.enqueue(new _IsolateContext(), function() { 600 _globalState.topEventLoop.enqueue(new _IsolateContext(), function() {
595 final func = _getJSFunctionFromName(functionName); 601 final func = _getJSFunctionFromName(functionName);
596 _startIsolate2(func, replyPort); 602 _startIsolate2(func, replyPort);
597 }, 'nonworker start'); 603 }, 'nonworker start');
598 } 604 }
599 605
600 static void _startIsolate2(Function topLevel, SendPort replyTo) { 606 static void _startIsolate2(Function topLevel, SendPort replyTo) {
601 _fillStatics(_globalState.currentContext); 607 _fillStatics(_globalState.currentContext);
602 _port = new ReceivePort(); 608 __port = new ReceivePort();
603 replyTo.send(_SPAWNED_SIGNAL, port.toSendPort()); 609 replyTo.send(_SPAWNED_SIGNAL, port.toSendPort());
604 topLevel(); 610 topLevel();
605 } 611 }
606 612
607 /** 613 /**
608 * Spawns an isolate in a worker. [factoryName] is the Javascript constructor 614 * Spawns an isolate in a worker. [factoryName] is the Javascript constructor
609 * name for the isolate entry point class. 615 * name for the isolate entry point class.
610 */ 616 */
611 static void _spawnWorker2(functionName, uri, replyPort) { 617 static void _spawnWorker2(functionName, uri, replyPort) {
612 if (functionName == null) functionName = 'main'; 618 if (functionName == null) functionName = 'main';
(...skipping 14 matching lines...) Expand all
627 'command': 'start2', 633 'command': 'start2',
628 'id': workerId, 634 'id': workerId,
629 // Note: we serialize replyPort twice because the child worker needs to 635 // Note: we serialize replyPort twice because the child worker needs to
630 // first deserialize the worker id, before it can correctly deserialize 636 // first deserialize the worker id, before it can correctly deserialize
631 // the port (port deserialization is sensitive to what is the current 637 // the port (port deserialization is sensitive to what is the current
632 // workerId). 638 // workerId).
633 'replyTo': _serializeMessage(replyPort), 639 'replyTo': _serializeMessage(replyPort),
634 'functionName': functionName })); 640 'functionName': functionName }));
635 } 641 }
636 } 642 }
OLDNEW
« no previous file with comments | « no previous file | tests/co19/co19-leg.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698