| OLD | NEW |
| 1 var _isolate_helper; | 1 var _isolate_helper; |
| 2 (function(exports) { | 2 (function(exports) { |
| 3 'use strict'; | 3 'use strict'; |
| 4 // Function _serializeMessage: (dynamic) → dynamic | 4 // Function _serializeMessage: (dynamic) → dynamic |
| 5 function _serializeMessage(message) { | 5 function _serializeMessage(message) { |
| 6 return new _Serializer().serialize(message); | 6 return new _Serializer().serialize(message); |
| 7 } | 7 } |
| 8 // Function _deserializeMessage: (dynamic) → dynamic | 8 // Function _deserializeMessage: (dynamic) → dynamic |
| 9 function _deserializeMessage(message) { | 9 function _deserializeMessage(message) { |
| 10 return new _Deserializer().deserialize(message); | 10 return new _Deserializer().deserialize(message); |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 } | 471 } |
| 472 } | 472 } |
| 473 let _controlPort = Symbol('_controlPort'); | 473 let _controlPort = Symbol('_controlPort'); |
| 474 let _scheduledControlEvents = Symbol('_scheduledControlEvents'); | 474 let _scheduledControlEvents = Symbol('_scheduledControlEvents'); |
| 475 let _isExecutingEvent = Symbol('_isExecutingEvent'); | 475 let _isExecutingEvent = Symbol('_isExecutingEvent'); |
| 476 let _updateGlobalState = Symbol('_updateGlobalState'); | 476 let _updateGlobalState = Symbol('_updateGlobalState'); |
| 477 let _setGlobals = Symbol('_setGlobals'); | 477 let _setGlobals = Symbol('_setGlobals'); |
| 478 let _addRegistration = Symbol('_addRegistration'); | 478 let _addRegistration = Symbol('_addRegistration'); |
| 479 class _IsolateContext extends core.Object { | 479 class _IsolateContext extends core.Object { |
| 480 _IsolateContext() { | 480 _IsolateContext() { |
| 481 this.id = ((x$) => exports._globalState.nextIsolateId = dart.notNull(x$) +
1, x$).bind(this)(exports._globalState.nextIsolateId); | 481 this.id = ((x$) => exports._globalState.nextIsolateId = dart.notNull(x$) +
1, x$)(exports._globalState.nextIsolateId); |
| 482 this.ports = new (core.Map$(core.int, RawReceivePortImpl))(); | 482 this.ports = new (core.Map$(core.int, RawReceivePortImpl))(); |
| 483 this.weakPorts = new (core.Set$(core.int))(); | 483 this.weakPorts = new (core.Set$(core.int))(); |
| 484 this.isolateStatics = _foreign_helper.JS_CREATE_ISOLATE(); | 484 this.isolateStatics = _foreign_helper.JS_CREATE_ISOLATE(); |
| 485 this.controlPort = new RawReceivePortImpl[_controlPort](); | 485 this.controlPort = new RawReceivePortImpl[_controlPort](); |
| 486 this.pauseCapability = new isolate.Capability(); | 486 this.pauseCapability = new isolate.Capability(); |
| 487 this.terminateCapability = new isolate.Capability(); | 487 this.terminateCapability = new isolate.Capability(); |
| 488 this.delayedEvents = dart.as(new core.List.from([]), core.List$(_IsolateEv
ent)); | 488 this.delayedEvents = dart.as(new core.List.from([]), core.List$(_IsolateEv
ent)); |
| 489 this.pauseTokens = dart.as(new core.Set(), core.Set$(isolate.Capability)); | 489 this.pauseTokens = dart.as(new core.Set(), core.Set$(isolate.Capability)); |
| 490 this.errorPorts = dart.as(new core.Set(), core.Set$(isolate.SendPort)); | 490 this.errorPorts = dart.as(new core.Set(), core.Set$(isolate.SendPort)); |
| 491 this.initialized = false; | 491 this.initialized = false; |
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 998 IsolateNatives.enableSpawnWorker = true; | 998 IsolateNatives.enableSpawnWorker = true; |
| 999 let isLight = false; | 999 let isLight = false; |
| 1000 let isSpawnUri = true; | 1000 let isSpawnUri = true; |
| 1001 return IsolateNatives.spawn(null, uri.toString(), args, message, isLight,
isSpawnUri, startPaused); | 1001 return IsolateNatives.spawn(null, uri.toString(), args, message, isLight,
isSpawnUri, startPaused); |
| 1002 } | 1002 } |
| 1003 static spawn(functionName, uri, args, message, isLight, isSpawnUri, startPau
sed) { | 1003 static spawn(functionName, uri, args, message, isLight, isSpawnUri, startPau
sed) { |
| 1004 if (dart.notNull(uri != null) && dart.notNull(uri.endsWith(".dart"))) | 1004 if (dart.notNull(uri != null) && dart.notNull(uri.endsWith(".dart"))) |
| 1005 uri = ".js"; | 1005 uri = ".js"; |
| 1006 let port = new isolate.ReceivePort(); | 1006 let port = new isolate.ReceivePort(); |
| 1007 let completer = dart.as(new async.Completer(), async.Completer$(core.List)
); | 1007 let completer = dart.as(new async.Completer(), async.Completer$(core.List)
); |
| 1008 port.first.then(((msg) => { | 1008 port.first.then((msg) => { |
| 1009 if (dart.equals(dart.dindex(msg, 0), _SPAWNED_SIGNAL)) { | 1009 if (dart.equals(dart.dindex(msg, 0), _SPAWNED_SIGNAL)) { |
| 1010 completer.complete(msg); | 1010 completer.complete(msg); |
| 1011 } else { | 1011 } else { |
| 1012 dart.assert(dart.equals(dart.dindex(msg, 0), _SPAWN_FAILED_SIGNAL)); | 1012 dart.assert(dart.equals(dart.dindex(msg, 0), _SPAWN_FAILED_SIGNAL)); |
| 1013 completer.completeError(dart.dindex(msg, 1)); | 1013 completer.completeError(dart.dindex(msg, 1)); |
| 1014 } | 1014 } |
| 1015 }).bind(this)); | 1015 }); |
| 1016 let signalReply = port.sendPort; | 1016 let signalReply = port.sendPort; |
| 1017 if (dart.notNull(exports._globalState.useWorkers) && !dart.notNull(isLight
)) { | 1017 if (dart.notNull(exports._globalState.useWorkers) && !dart.notNull(isLight
)) { |
| 1018 IsolateNatives[_startWorker](functionName, uri, args, message, isSpawnUr
i, startPaused, signalReply, ((message) => completer.completeError(message)).bin
d(this)); | 1018 IsolateNatives[_startWorker](functionName, uri, args, message, isSpawnUr
i, startPaused, signalReply, (message) => completer.completeError(message)); |
| 1019 } else { | 1019 } else { |
| 1020 IsolateNatives[_startNonWorker](functionName, uri, args, message, isSpaw
nUri, startPaused, signalReply); | 1020 IsolateNatives[_startNonWorker](functionName, uri, args, message, isSpaw
nUri, startPaused, signalReply); |
| 1021 } | 1021 } |
| 1022 return completer.future; | 1022 return completer.future; |
| 1023 } | 1023 } |
| 1024 static [_startWorker](functionName, uri, args, message, isSpawnUri, startPau
sed, replyPort, onError) { | 1024 static [_startWorker](functionName, uri, args, message, isSpawnUri, startPau
sed, replyPort, onError) { |
| 1025 if (args != null) | 1025 if (args != null) |
| 1026 args = new core.List$(core.String).from(args); | 1026 args = new core.List$(core.String).from(args); |
| 1027 if (exports._globalState.isWorker) { | 1027 if (exports._globalState.isWorker) { |
| 1028 exports._globalState.mainManager.postMessage(_serializeMessage(dart.map(
{command: 'spawn-worker', functionName: functionName, args: args, msg: message,
uri: uri, isSpawnUri: isSpawnUri, startPaused: startPaused, replyPort: replyPort
}))); | 1028 exports._globalState.mainManager.postMessage(_serializeMessage(dart.map(
{command: 'spawn-worker', functionName: functionName, args: args, msg: message,
uri: uri, isSpawnUri: isSpawnUri, startPaused: startPaused, replyPort: replyPort
}))); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1080 }; | 1080 }; |
| 1081 }(_foreign_helper.DART_CLOSURE_TO_JS(IsolateNatives.workerOnError), uri, o
nError); | 1081 }(_foreign_helper.DART_CLOSURE_TO_JS(IsolateNatives.workerOnError), uri, o
nError); |
| 1082 worker.onerror = onerrorTrampoline; | 1082 worker.onerror = onerrorTrampoline; |
| 1083 let processWorkerMessageTrampoline = function(f, a) { | 1083 let processWorkerMessageTrampoline = function(f, a) { |
| 1084 return function(e) { | 1084 return function(e) { |
| 1085 e.onerror = null; | 1085 e.onerror = null; |
| 1086 return f(a, e); | 1086 return f(a, e); |
| 1087 }; | 1087 }; |
| 1088 }(_foreign_helper.DART_CLOSURE_TO_JS(IsolateNatives[_processWorkerMessage]
), worker); | 1088 }(_foreign_helper.DART_CLOSURE_TO_JS(IsolateNatives[_processWorkerMessage]
), worker); |
| 1089 worker.onmessage = processWorkerMessageTrampoline; | 1089 worker.onmessage = processWorkerMessageTrampoline; |
| 1090 let workerId = ((x$) => exports._globalState.nextManagerId = dart.notNull(
x$) + 1, x$).bind(this)(exports._globalState.nextManagerId); | 1090 let workerId = ((x$) => exports._globalState.nextManagerId = dart.notNull(
x$) + 1, x$)(exports._globalState.nextManagerId); |
| 1091 IsolateNatives.workerIds.set(worker, workerId); | 1091 IsolateNatives.workerIds.set(worker, workerId); |
| 1092 exports._globalState.managers.set(workerId, worker); | 1092 exports._globalState.managers.set(workerId, worker); |
| 1093 worker.postMessage(_serializeMessage(dart.map({command: 'start', id: worke
rId, replyTo: _serializeMessage(replyPort), args: args, msg: _serializeMessage(m
essage), isSpawnUri: isSpawnUri, startPaused: startPaused, functionName: functio
nName}))); | 1093 worker.postMessage(_serializeMessage(dart.map({command: 'start', id: worke
rId, replyTo: _serializeMessage(replyPort), args: args, msg: _serializeMessage(m
essage), isSpawnUri: isSpawnUri, startPaused: startPaused, functionName: functio
nName}))); |
| 1094 } | 1094 } |
| 1095 static workerOnError(event, uri, onError) { | 1095 static workerOnError(event, uri, onError) { |
| 1096 event.preventDefault(); | 1096 event.preventDefault(); |
| 1097 let message = dart.as(event.message, core.String); | 1097 let message = dart.as(event.message, core.String); |
| 1098 if (message == null) { | 1098 if (message == null) { |
| 1099 message = `Error spawning worker for ${uri}`; | 1099 message = `Error spawning worker for ${uri}`; |
| 1100 } else { | 1100 } else { |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1372 exports.leaveJsAsync = leaveJsAsync; | 1372 exports.leaveJsAsync = leaveJsAsync; |
| 1373 exports.isWorker = isWorker; | 1373 exports.isWorker = isWorker; |
| 1374 exports.startRootIsolate = startRootIsolate; | 1374 exports.startRootIsolate = startRootIsolate; |
| 1375 exports.IsolateNatives = IsolateNatives; | 1375 exports.IsolateNatives = IsolateNatives; |
| 1376 exports.RawReceivePortImpl = RawReceivePortImpl; | 1376 exports.RawReceivePortImpl = RawReceivePortImpl; |
| 1377 exports.ReceivePortImpl = ReceivePortImpl; | 1377 exports.ReceivePortImpl = ReceivePortImpl; |
| 1378 exports.TimerImpl = TimerImpl; | 1378 exports.TimerImpl = TimerImpl; |
| 1379 exports.hasTimer = hasTimer; | 1379 exports.hasTimer = hasTimer; |
| 1380 exports.CapabilityImpl = CapabilityImpl; | 1380 exports.CapabilityImpl = CapabilityImpl; |
| 1381 })(_isolate_helper || (_isolate_helper = {})); | 1381 })(_isolate_helper || (_isolate_helper = {})); |
| OLD | NEW |