| OLD | NEW |
| 1 dart_library.library('dart/_isolate_helper', null, /* Imports */[ | 1 dart_library.library('dart/_isolate_helper', null, /* Imports */[ |
| 2 'dart/_runtime', | 2 'dart/_runtime', |
| 3 'dart/core', | 3 'dart/core', |
| 4 'dart/_native_typed_data', | 4 'dart/_native_typed_data', |
| 5 'dart/_interceptors', | 5 'dart/_interceptors', |
| 6 'dart/_js_helper', | 6 'dart/_js_helper', |
| 7 'dart/isolate', | 7 'dart/isolate', |
| 8 'dart/_foreign_helper', | 8 'dart/_foreign_helper', |
| 9 'dart/_js_embedded_names', | 9 'dart/_js_embedded_names', |
| 10 'dart/collection', | 10 'dart/collection', |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 const _id = Symbol('_id'); | 34 const _id = Symbol('_id'); |
| 35 const _receivePort = Symbol('_receivePort'); | 35 const _receivePort = Symbol('_receivePort'); |
| 36 class _Serializer extends core.Object { | 36 class _Serializer extends core.Object { |
| 37 _Serializer(opts) { | 37 _Serializer(opts) { |
| 38 let serializeSendPorts = opts && 'serializeSendPorts' in opts ? opts.seria
lizeSendPorts : true; | 38 let serializeSendPorts = opts && 'serializeSendPorts' in opts ? opts.seria
lizeSendPorts : true; |
| 39 this.serializedObjectIds = core.Map$(dart.dynamic, core.int).identity(); | 39 this.serializedObjectIds = core.Map$(dart.dynamic, core.int).identity(); |
| 40 this[_serializeSendPorts] = dart.as(serializeSendPorts, core.bool); | 40 this[_serializeSendPorts] = dart.as(serializeSendPorts, core.bool); |
| 41 } | 41 } |
| 42 serialize(x) { | 42 serialize(x) { |
| 43 if (dart.notNull(this.isPrimitive(x))) return this.serializePrimitive(x); | 43 if (dart.notNull(this.isPrimitive(x))) return this.serializePrimitive(x); |
| 44 let serializationId = this.serializedObjectIds.get(x); | 44 let serializationId = this.serializedObjectIds[dartx.get](x); |
| 45 if (serializationId != null) return this.makeRef(serializationId); | 45 if (serializationId != null) return this.makeRef(serializationId); |
| 46 serializationId = this.serializedObjectIds.length; | 46 serializationId = this.serializedObjectIds[dartx.length]; |
| 47 this.serializedObjectIds.set(x, serializationId); | 47 this.serializedObjectIds[dartx.set](x, serializationId); |
| 48 if (dart.is(x, _native_typed_data.NativeByteBuffer)) return this.serialize
ByteBuffer(x); | 48 if (dart.is(x, _native_typed_data.NativeByteBuffer)) return this.serialize
ByteBuffer(x); |
| 49 if (dart.is(x, _native_typed_data.NativeTypedData)) return this.serializeT
ypedData(x); | 49 if (dart.is(x, _native_typed_data.NativeTypedData)) return this.serializeT
ypedData(x); |
| 50 if (dart.is(x, _interceptors.JSIndexable)) return this.serializeJSIndexabl
e(x); | 50 if (dart.is(x, _interceptors.JSIndexable)) return this.serializeJSIndexabl
e(x); |
| 51 if (dart.is(x, _js_helper.InternalMap)) return this.serializeMap(x); | 51 if (dart.is(x, _js_helper.InternalMap)) return this.serializeMap(x); |
| 52 if (dart.is(x, _interceptors.JSObject)) return this.serializeJSObject(x); | 52 if (dart.is(x, _interceptors.JSObject)) return this.serializeJSObject(x); |
| 53 if (dart.is(x, _interceptors.Interceptor)) this.unsupported(x); | 53 if (dart.is(x, _interceptors.Interceptor)) this.unsupported(x); |
| 54 if (dart.is(x, isolate.RawReceivePort)) { | 54 if (dart.is(x, isolate.RawReceivePort)) { |
| 55 this.unsupported(x, "RawReceivePorts can't be transmitted:"); | 55 this.unsupported(x, "RawReceivePorts can't be transmitted:"); |
| 56 } | 56 } |
| 57 if (dart.is(x, _NativeJsSendPort)) return this.serializeJsSendPort(x); | 57 if (dart.is(x, _NativeJsSendPort)) return this.serializeJsSendPort(x); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 return serialized; | 98 return serialized; |
| 99 } | 99 } |
| 100 serializeArrayInPlace(x) { | 100 serializeArrayInPlace(x) { |
| 101 for (let i = 0; i < dart.notNull(x[dartx.length]); i++) { | 101 for (let i = 0; i < dart.notNull(x[dartx.length]); i++) { |
| 102 x[dartx.set](i, this.serialize(x[dartx.get](i))); | 102 x[dartx.set](i, this.serialize(x[dartx.get](i))); |
| 103 } | 103 } |
| 104 return x; | 104 return x; |
| 105 } | 105 } |
| 106 serializeMap(x) { | 106 serializeMap(x) { |
| 107 let serializeTearOff = dart.bind(this, 'serialize'); | 107 let serializeTearOff = dart.bind(this, 'serialize'); |
| 108 return ['map', x.keys[dartx.map](dart.as(serializeTearOff, __CastType0))[d
artx.toList](), x.values[dartx.map](dart.as(serializeTearOff, dart.functionType(
dart.dynamic, [dart.dynamic])))[dartx.toList]()]; | 108 return ['map', x[dartx.keys][dartx.map](dart.as(serializeTearOff, __CastTy
pe0))[dartx.toList](), x[dartx.values][dartx.map](dart.as(serializeTearOff, dart
.functionType(dart.dynamic, [dart.dynamic])))[dartx.toList]()]; |
| 109 } | 109 } |
| 110 serializeJSObject(x) { | 110 serializeJSObject(x) { |
| 111 if (!!x.constructor && x.constructor !== Object) { | 111 if (!!x.constructor && x.constructor !== Object) { |
| 112 this.unsupported(x, "Only plain JS Objects are supported:"); | 112 this.unsupported(x, "Only plain JS Objects are supported:"); |
| 113 } | 113 } |
| 114 let keys = dart.as(Object.keys(x), core.List); | 114 let keys = dart.as(Object.keys(x), core.List); |
| 115 let values = []; | 115 let values = []; |
| 116 values[dartx.length] = keys[dartx.length]; | 116 values[dartx.length] = keys[dartx.length]; |
| 117 for (let i = 0; i < dart.notNull(keys[dartx.length]); i++) { | 117 for (let i = 0; i < dart.notNull(keys[dartx.length]); i++) { |
| 118 values[dartx.set](i, this.serialize(x[keys[dartx.get](i)])); | 118 values[dartx.set](i, this.serialize(x[keys[dartx.get](i)])); |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 return _interceptors.JSArray.markFixed(this.deserializeArrayInPlace(dart.a
s(result, _interceptors.JSArray))); | 295 return _interceptors.JSArray.markFixed(this.deserializeArrayInPlace(dart.a
s(result, _interceptors.JSArray))); |
| 296 } | 296 } |
| 297 deserializeMap(x) { | 297 deserializeMap(x) { |
| 298 dart.assert(dart.equals(dart.dindex(x, 0), 'map')); | 298 dart.assert(dart.equals(dart.dindex(x, 0), 'map')); |
| 299 let keys = dart.as(dart.dindex(x, 1), core.List); | 299 let keys = dart.as(dart.dindex(x, 1), core.List); |
| 300 let values = dart.as(dart.dindex(x, 2), core.List); | 300 let values = dart.as(dart.dindex(x, 2), core.List); |
| 301 let result = dart.map(); | 301 let result = dart.map(); |
| 302 this.deserializedObjects[dartx.add](result); | 302 this.deserializedObjects[dartx.add](result); |
| 303 keys = keys[dartx.map](dart.bind(this, 'deserialize'))[dartx.toList](); | 303 keys = keys[dartx.map](dart.bind(this, 'deserialize'))[dartx.toList](); |
| 304 for (let i = 0; i < dart.notNull(keys[dartx.length]); i++) { | 304 for (let i = 0; i < dart.notNull(keys[dartx.length]); i++) { |
| 305 result.set(keys[dartx.get](i), this.deserialize(values[dartx.get](i))); | 305 result[dartx.set](keys[dartx.get](i), this.deserialize(values[dartx.get]
(i))); |
| 306 } | 306 } |
| 307 return result; | 307 return result; |
| 308 } | 308 } |
| 309 deserializeSendPort(x) { | 309 deserializeSendPort(x) { |
| 310 dart.assert(dart.equals(dart.dindex(x, 0), 'sendport')); | 310 dart.assert(dart.equals(dart.dindex(x, 0), 'sendport')); |
| 311 let managerId = dart.as(dart.dindex(x, 1), core.int); | 311 let managerId = dart.as(dart.dindex(x, 1), core.int); |
| 312 let isolateId = dart.as(dart.dindex(x, 2), core.int); | 312 let isolateId = dart.as(dart.dindex(x, 2), core.int); |
| 313 let receivePortId = dart.as(dart.dindex(x, 3), core.int); | 313 let receivePortId = dart.as(dart.dindex(x, 3), core.int); |
| 314 let result = null; | 314 let result = null; |
| 315 if (managerId == exports._globalState.currentManagerId) { | 315 if (managerId == exports._globalState.currentManagerId) { |
| 316 let isolate = exports._globalState.isolates.get(isolateId); | 316 let isolate = exports._globalState.isolates[dartx.get](isolateId); |
| 317 if (isolate == null) return null; | 317 if (isolate == null) return null; |
| 318 let receivePort = isolate.lookup(receivePortId); | 318 let receivePort = isolate.lookup(receivePortId); |
| 319 if (receivePort == null) return null; | 319 if (receivePort == null) return null; |
| 320 result = new _NativeJsSendPort(receivePort, isolateId); | 320 result = new _NativeJsSendPort(receivePort, isolateId); |
| 321 } else { | 321 } else { |
| 322 result = new _WorkerSendPort(managerId, isolateId, receivePortId); | 322 result = new _WorkerSendPort(managerId, isolateId, receivePortId); |
| 323 } | 323 } |
| 324 this.deserializedObjects[dartx.add](result); | 324 this.deserializedObjects[dartx.add](result); |
| 325 return result; | 325 return result; |
| 326 } | 326 } |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 } else { | 492 } else { |
| 493 self.postMessage(serialize(object)); | 493 self.postMessage(serialize(object)); |
| 494 } | 494 } |
| 495 }; | 495 }; |
| 496 })(_Manager._serializePrintMessage); | 496 })(_Manager._serializePrintMessage); |
| 497 } | 497 } |
| 498 static _serializePrintMessage(object) { | 498 static _serializePrintMessage(object) { |
| 499 return _serializeMessage(dart.map({command: "print", msg: object})); | 499 return _serializeMessage(dart.map({command: "print", msg: object})); |
| 500 } | 500 } |
| 501 maybeCloseWorker() { | 501 maybeCloseWorker() { |
| 502 if (dart.notNull(this.isWorker) && dart.notNull(this.isolates.isEmpty) &&
this.topEventLoop[_activeJsAsyncCount] == 0) { | 502 if (dart.notNull(this.isWorker) && dart.notNull(this.isolates[dartx.isEmpt
y]) && this.topEventLoop[_activeJsAsyncCount] == 0) { |
| 503 this.mainManager.postMessage(_serializeMessage(dart.map({command: 'close
'}))); | 503 this.mainManager.postMessage(_serializeMessage(dart.map({command: 'close
'}))); |
| 504 } | 504 } |
| 505 } | 505 } |
| 506 } | 506 } |
| 507 dart.setSignature(_Manager, { | 507 dart.setSignature(_Manager, { |
| 508 constructors: () => ({_Manager: [_Manager, [core.Function]]}), | 508 constructors: () => ({_Manager: [_Manager, [core.Function]]}), |
| 509 methods: () => ({ | 509 methods: () => ({ |
| 510 [_nativeDetectEnvironment]: [dart.void, []], | 510 [_nativeDetectEnvironment]: [dart.void, []], |
| 511 [_nativeInitWorkerMessageHandler]: [dart.void, []], | 511 [_nativeInitWorkerMessageHandler]: [dart.void, []], |
| 512 maybeCloseWorker: [dart.void, []] | 512 maybeCloseWorker: [dart.void, []] |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 } | 715 } |
| 716 case "stopErrors": | 716 case "stopErrors": |
| 717 { | 717 { |
| 718 this.removeErrorListener(dart.as(dart.dindex(message, 1), isolate.Send
Port)); | 718 this.removeErrorListener(dart.as(dart.dindex(message, 1), isolate.Send
Port)); |
| 719 break; | 719 break; |
| 720 } | 720 } |
| 721 default: | 721 default: |
| 722 } | 722 } |
| 723 } | 723 } |
| 724 lookup(portId) { | 724 lookup(portId) { |
| 725 return this.ports.get(portId); | 725 return this.ports[dartx.get](portId); |
| 726 } | 726 } |
| 727 [_addRegistration](portId, port) { | 727 [_addRegistration](portId, port) { |
| 728 if (dart.notNull(this.ports.containsKey(portId))) { | 728 if (dart.notNull(this.ports[dartx.containsKey](portId))) { |
| 729 dart.throw(core.Exception.new("Registry: ports must be registered only o
nce.")); | 729 dart.throw(core.Exception.new("Registry: ports must be registered only o
nce.")); |
| 730 } | 730 } |
| 731 this.ports.set(portId, port); | 731 this.ports[dartx.set](portId, port); |
| 732 } | 732 } |
| 733 register(portId, port) { | 733 register(portId, port) { |
| 734 this[_addRegistration](portId, port); | 734 this[_addRegistration](portId, port); |
| 735 this[_updateGlobalState](); | 735 this[_updateGlobalState](); |
| 736 } | 736 } |
| 737 registerWeak(portId, port) { | 737 registerWeak(portId, port) { |
| 738 this.weakPorts.add(portId); | 738 this.weakPorts.add(portId); |
| 739 this[_addRegistration](portId, port); | 739 this[_addRegistration](portId, port); |
| 740 } | 740 } |
| 741 [_updateGlobalState]() { | 741 [_updateGlobalState]() { |
| 742 if (dart.notNull(this.ports.length) - dart.notNull(this.weakPorts.length)
> 0 || dart.notNull(this.isPaused) || !dart.notNull(this.initialized)) { | 742 if (dart.notNull(this.ports[dartx.length]) - dart.notNull(this.weakPorts.l
ength) > 0 || dart.notNull(this.isPaused) || !dart.notNull(this.initialized)) { |
| 743 exports._globalState.isolates.set(this.id, this); | 743 exports._globalState.isolates[dartx.set](this.id, this); |
| 744 } else { | 744 } else { |
| 745 this.kill(); | 745 this.kill(); |
| 746 } | 746 } |
| 747 } | 747 } |
| 748 kill() { | 748 kill() { |
| 749 if (this[_scheduledControlEvents] != null) { | 749 if (this[_scheduledControlEvents] != null) { |
| 750 dart.dsend(this[_scheduledControlEvents], 'clear'); | 750 dart.dsend(this[_scheduledControlEvents], 'clear'); |
| 751 } | 751 } |
| 752 for (let port of this.ports.values) { | 752 for (let port of this.ports[dartx.values]) { |
| 753 port[_close](); | 753 port[_close](); |
| 754 } | 754 } |
| 755 this.ports.clear(); | 755 this.ports[dartx.clear](); |
| 756 this.weakPorts.clear(); | 756 this.weakPorts.clear(); |
| 757 exports._globalState.isolates.remove(this.id); | 757 exports._globalState.isolates[dartx.remove](this.id); |
| 758 this.errorPorts.clear(); | 758 this.errorPorts.clear(); |
| 759 if (this.doneHandlers != null) { | 759 if (this.doneHandlers != null) { |
| 760 for (let port of dart.as(this.doneHandlers, core.Iterable$(isolate.SendP
ort))) { | 760 for (let port of dart.as(this.doneHandlers, core.Iterable$(isolate.SendP
ort))) { |
| 761 port.send(null); | 761 port.send(null); |
| 762 } | 762 } |
| 763 this.doneHandlers = null; | 763 this.doneHandlers = null; |
| 764 } | 764 } |
| 765 } | 765 } |
| 766 unregister(portId) { | 766 unregister(portId) { |
| 767 this.ports.remove(portId); | 767 this.ports[dartx.remove](portId); |
| 768 this.weakPorts.remove(portId); | 768 this.weakPorts.remove(portId); |
| 769 this[_updateGlobalState](); | 769 this[_updateGlobalState](); |
| 770 } | 770 } |
| 771 } | 771 } |
| 772 _IsolateContext[dart.implements] = () => [_foreign_helper.IsolateContext]; | 772 _IsolateContext[dart.implements] = () => [_foreign_helper.IsolateContext]; |
| 773 dart.setSignature(_IsolateContext, { | 773 dart.setSignature(_IsolateContext, { |
| 774 constructors: () => ({_IsolateContext: [_IsolateContext, []]}), | 774 constructors: () => ({_IsolateContext: [_IsolateContext, []]}), |
| 775 methods: () => ({ | 775 methods: () => ({ |
| 776 addPause: [dart.void, [isolate.Capability, isolate.Capability]], | 776 addPause: [dart.void, [isolate.Capability, isolate.Capability]], |
| 777 removePause: [dart.void, [isolate.Capability]], | 777 removePause: [dart.void, [isolate.Capability]], |
| (...skipping 27 matching lines...) Expand all Loading... |
| 805 this.events.addLast(new _IsolateEvent(dart.as(isolate, _IsolateContext), d
art.as(fn, core.Function), dart.as(msg, core.String))); | 805 this.events.addLast(new _IsolateEvent(dart.as(isolate, _IsolateContext), d
art.as(fn, core.Function), dart.as(msg, core.String))); |
| 806 } | 806 } |
| 807 prequeue(event) { | 807 prequeue(event) { |
| 808 this.events.addFirst(event); | 808 this.events.addFirst(event); |
| 809 } | 809 } |
| 810 dequeue() { | 810 dequeue() { |
| 811 if (dart.notNull(this.events.isEmpty)) return null; | 811 if (dart.notNull(this.events.isEmpty)) return null; |
| 812 return this.events.removeFirst(); | 812 return this.events.removeFirst(); |
| 813 } | 813 } |
| 814 checkOpenReceivePortsFromCommandLine() { | 814 checkOpenReceivePortsFromCommandLine() { |
| 815 if (exports._globalState.rootContext != null && dart.notNull(exports._glob
alState.isolates.containsKey(exports._globalState.rootContext.id)) && dart.notNu
ll(exports._globalState.fromCommandLine) && dart.notNull(exports._globalState.ro
otContext.ports.isEmpty)) { | 815 if (exports._globalState.rootContext != null && dart.notNull(exports._glob
alState.isolates[dartx.containsKey](exports._globalState.rootContext.id)) && dar
t.notNull(exports._globalState.fromCommandLine) && dart.notNull(exports._globalS
tate.rootContext.ports[dartx.isEmpty])) { |
| 816 dart.throw(core.Exception.new("Program exited with open ReceivePorts."))
; | 816 dart.throw(core.Exception.new("Program exited with open ReceivePorts."))
; |
| 817 } | 817 } |
| 818 } | 818 } |
| 819 runIteration() { | 819 runIteration() { |
| 820 let event = this.dequeue(); | 820 let event = this.dequeue(); |
| 821 if (event == null) { | 821 if (event == null) { |
| 822 this.checkOpenReceivePortsFromCommandLine(); | 822 this.checkOpenReceivePortsFromCommandLine(); |
| 823 exports._globalState.maybeCloseWorker(); | 823 exports._globalState.maybeCloseWorker(); |
| 824 return false; | 824 return false; |
| 825 } | 825 } |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 982 { | 982 { |
| 983 let port = dart.as(dart.dindex(msg, 'port'), isolate.SendPort); | 983 let port = dart.as(dart.dindex(msg, 'port'), isolate.SendPort); |
| 984 if (port != null) { | 984 if (port != null) { |
| 985 dart.dsend(dart.dindex(msg, 'port'), 'send', dart.dindex(msg, 'msg')
); | 985 dart.dsend(dart.dindex(msg, 'port'), 'send', dart.dindex(msg, 'msg')
); |
| 986 } | 986 } |
| 987 exports._globalState.topEventLoop.run(); | 987 exports._globalState.topEventLoop.run(); |
| 988 break; | 988 break; |
| 989 } | 989 } |
| 990 case 'close': | 990 case 'close': |
| 991 { | 991 { |
| 992 exports._globalState.managers.remove(IsolateNatives.workerIds.get(send
er)); | 992 exports._globalState.managers[dartx.remove](IsolateNatives.workerIds.g
et(sender)); |
| 993 sender.terminate(); | 993 sender.terminate(); |
| 994 exports._globalState.topEventLoop.run(); | 994 exports._globalState.topEventLoop.run(); |
| 995 break; | 995 break; |
| 996 } | 996 } |
| 997 case 'log': | 997 case 'log': |
| 998 { | 998 { |
| 999 IsolateNatives._log(dart.dindex(msg, 'msg')); | 999 IsolateNatives._log(dart.dindex(msg, 'msg')); |
| 1000 break; | 1000 break; |
| 1001 } | 1001 } |
| 1002 case 'print': | 1002 case 'print': |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1146 return function(e) { | 1146 return function(e) { |
| 1147 e.onerror = null; | 1147 e.onerror = null; |
| 1148 return f(a, e); | 1148 return f(a, e); |
| 1149 }; | 1149 }; |
| 1150 })(IsolateNatives._processWorkerMessage, worker); | 1150 })(IsolateNatives._processWorkerMessage, worker); |
| 1151 worker.onmessage = processWorkerMessageTrampoline; | 1151 worker.onmessage = processWorkerMessageTrampoline; |
| 1152 let o = exports._globalState; | 1152 let o = exports._globalState; |
| 1153 let workerId = o.nextManagerId; | 1153 let workerId = o.nextManagerId; |
| 1154 o.nextManagerId = dart.notNull(workerId) + 1; | 1154 o.nextManagerId = dart.notNull(workerId) + 1; |
| 1155 IsolateNatives.workerIds.set(worker, workerId); | 1155 IsolateNatives.workerIds.set(worker, workerId); |
| 1156 exports._globalState.managers.set(workerId, worker); | 1156 exports._globalState.managers[dartx.set](workerId, worker); |
| 1157 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}))); | 1157 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}))); |
| 1158 } | 1158 } |
| 1159 static workerOnError(event, uri, onError) { | 1159 static workerOnError(event, uri, onError) { |
| 1160 event.preventDefault(); | 1160 event.preventDefault(); |
| 1161 let message = dart.as(event.message, core.String); | 1161 let message = dart.as(event.message, core.String); |
| 1162 if (message == null) { | 1162 if (message == null) { |
| 1163 message = `Error spawning worker for ${uri}`; | 1163 message = `Error spawning worker for ${uri}`; |
| 1164 } else { | 1164 } else { |
| 1165 message = `Error spawning worker for ${uri} (${message})`; | 1165 message = `Error spawning worker for ${uri} (${message})`; |
| 1166 } | 1166 } |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1220 methods: () => ({[_checkReplyTo]: [dart.void, [isolate.SendPort]]}) | 1220 methods: () => ({[_checkReplyTo]: [dart.void, [isolate.SendPort]]}) |
| 1221 }); | 1221 }); |
| 1222 const _isClosed = Symbol('_isClosed'); | 1222 const _isClosed = Symbol('_isClosed'); |
| 1223 const _add = Symbol('_add'); | 1223 const _add = Symbol('_add'); |
| 1224 class _NativeJsSendPort extends _BaseSendPort { | 1224 class _NativeJsSendPort extends _BaseSendPort { |
| 1225 _NativeJsSendPort(receivePort, isolateId) { | 1225 _NativeJsSendPort(receivePort, isolateId) { |
| 1226 this[_receivePort] = receivePort; | 1226 this[_receivePort] = receivePort; |
| 1227 super._BaseSendPort(isolateId); | 1227 super._BaseSendPort(isolateId); |
| 1228 } | 1228 } |
| 1229 send(message) { | 1229 send(message) { |
| 1230 let isolate = exports._globalState.isolates.get(this[_isolateId]); | 1230 let isolate = exports._globalState.isolates[dartx.get](this[_isolateId]); |
| 1231 if (isolate == null) return; | 1231 if (isolate == null) return; |
| 1232 if (dart.notNull(this[_receivePort][_isClosed])) return; | 1232 if (dart.notNull(this[_receivePort][_isClosed])) return; |
| 1233 let msg = _clone(message); | 1233 let msg = _clone(message); |
| 1234 if (dart.equals(isolate.controlPort, this[_receivePort])) { | 1234 if (dart.equals(isolate.controlPort, this[_receivePort])) { |
| 1235 isolate.handleControlMessage(msg); | 1235 isolate.handleControlMessage(msg); |
| 1236 return; | 1236 return; |
| 1237 } | 1237 } |
| 1238 exports._globalState.topEventLoop.enqueue(isolate, dart.fn(() => { | 1238 exports._globalState.topEventLoop.enqueue(isolate, dart.fn(() => { |
| 1239 if (!dart.notNull(this[_receivePort][_isClosed])) { | 1239 if (!dart.notNull(this[_receivePort][_isClosed])) { |
| 1240 this[_receivePort][_add](msg); | 1240 this[_receivePort][_add](msg); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1257 _WorkerSendPort(workerId, isolateId, receivePortId) { | 1257 _WorkerSendPort(workerId, isolateId, receivePortId) { |
| 1258 this[_workerId] = workerId; | 1258 this[_workerId] = workerId; |
| 1259 this[_receivePortId] = receivePortId; | 1259 this[_receivePortId] = receivePortId; |
| 1260 super._BaseSendPort(isolateId); | 1260 super._BaseSendPort(isolateId); |
| 1261 } | 1261 } |
| 1262 send(message) { | 1262 send(message) { |
| 1263 let workerMessage = _serializeMessage(dart.map({command: 'message', port:
this, msg: message})); | 1263 let workerMessage = _serializeMessage(dart.map({command: 'message', port:
this, msg: message})); |
| 1264 if (dart.notNull(exports._globalState.isWorker)) { | 1264 if (dart.notNull(exports._globalState.isWorker)) { |
| 1265 exports._globalState.mainManager.postMessage(workerMessage); | 1265 exports._globalState.mainManager.postMessage(workerMessage); |
| 1266 } else { | 1266 } else { |
| 1267 let manager = exports._globalState.managers.get(this[_workerId]); | 1267 let manager = exports._globalState.managers[dartx.get](this[_workerId]); |
| 1268 if (manager != null) { | 1268 if (manager != null) { |
| 1269 manager.postMessage(workerMessage); | 1269 manager.postMessage(workerMessage); |
| 1270 } | 1270 } |
| 1271 } | 1271 } |
| 1272 } | 1272 } |
| 1273 ['=='](other) { | 1273 ['=='](other) { |
| 1274 return dart.is(other, _WorkerSendPort) && this[_workerId] == other[_worker
Id] && this[_isolateId] == other[_isolateId] && this[_receivePortId] == other[_r
eceivePortId]; | 1274 return dart.is(other, _WorkerSendPort) && this[_workerId] == other[_worker
Id] && this[_isolateId] == other[_isolateId] && this[_receivePortId] == other[_r
eceivePortId]; |
| 1275 } | 1275 } |
| 1276 get hashCode() { | 1276 get hashCode() { |
| 1277 return dart.notNull(this[_workerId]) << 16 ^ dart.notNull(this[_isolateId]
) << 8 ^ dart.notNull(this[_receivePortId]); | 1277 return dart.notNull(this[_workerId]) << 16 ^ dart.notNull(this[_isolateId]
) << 8 ^ dart.notNull(this[_receivePortId]); |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1508 exports.leaveJsAsync = leaveJsAsync; | 1508 exports.leaveJsAsync = leaveJsAsync; |
| 1509 exports.isWorker = isWorker; | 1509 exports.isWorker = isWorker; |
| 1510 exports.startRootIsolate = startRootIsolate; | 1510 exports.startRootIsolate = startRootIsolate; |
| 1511 exports.IsolateNatives = IsolateNatives; | 1511 exports.IsolateNatives = IsolateNatives; |
| 1512 exports.RawReceivePortImpl = RawReceivePortImpl; | 1512 exports.RawReceivePortImpl = RawReceivePortImpl; |
| 1513 exports.ReceivePortImpl = ReceivePortImpl; | 1513 exports.ReceivePortImpl = ReceivePortImpl; |
| 1514 exports.TimerImpl = TimerImpl; | 1514 exports.TimerImpl = TimerImpl; |
| 1515 exports.hasTimer = hasTimer; | 1515 exports.hasTimer = hasTimer; |
| 1516 exports.CapabilityImpl = CapabilityImpl; | 1516 exports.CapabilityImpl = CapabilityImpl; |
| 1517 }); | 1517 }); |
| OLD | NEW |