| OLD | NEW |
| 1 dart_library.library('dart/isolate', null, /* Imports */[ | 1 dart_library.library('dart/isolate', null, /* Imports */[ |
| 2 'dart/_runtime', | 2 'dart/_runtime', |
| 3 'dart/core', | 3 'dart/core', |
| 4 'dart/async' | 4 'dart/async' |
| 5 ], /* Lazy imports */[ | 5 ], /* Lazy imports */[ |
| 6 'dart/_isolate_helper' | 6 'dart/_isolate_helper' |
| 7 ], function(exports, dart, core, async, _isolate_helper) { | 7 ], function(exports, dart, core, $async, _isolate_helper) { |
| 8 'use strict'; | 8 'use strict'; |
| 9 let dartx = dart.dartx; | 9 let dartx = dart.dartx; |
| 10 class Capability extends core.Object { | 10 class Capability extends core.Object { |
| 11 static new() { | 11 static new() { |
| 12 return new _isolate_helper.CapabilityImpl(); | 12 return new _isolate_helper.CapabilityImpl(); |
| 13 } | 13 } |
| 14 } | 14 } |
| 15 dart.setSignature(Capability, { | 15 dart.setSignature(Capability, { |
| 16 constructors: () => ({new: [Capability, []]}) | 16 constructors: () => ({new: [Capability, []]}) |
| 17 }); | 17 }); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 38 } | 38 } |
| 39 static get current() { | 39 static get current() { |
| 40 return Isolate._currentIsolateCache; | 40 return Isolate._currentIsolateCache; |
| 41 } | 41 } |
| 42 static spawn(entryPoint, message, opts) { | 42 static spawn(entryPoint, message, opts) { |
| 43 let paused = opts && 'paused' in opts ? opts.paused : false; | 43 let paused = opts && 'paused' in opts ? opts.paused : false; |
| 44 try { | 44 try { |
| 45 return _isolate_helper.IsolateNatives.spawnFunction(entryPoint, message,
paused).then(dart.fn(msg => new Isolate(dart.as(msg[dartx.get](1), SendPort), {
pauseCapability: dart.as(msg[dartx.get](2), Capability), terminateCapability: da
rt.as(msg[dartx.get](3), Capability)}), Isolate, [core.List])); | 45 return _isolate_helper.IsolateNatives.spawnFunction(entryPoint, message,
paused).then(dart.fn(msg => new Isolate(dart.as(msg[dartx.get](1), SendPort), {
pauseCapability: dart.as(msg[dartx.get](2), Capability), terminateCapability: da
rt.as(msg[dartx.get](3), Capability)}), Isolate, [core.List])); |
| 46 } catch (e) { | 46 } catch (e) { |
| 47 let st = dart.stackTrace(e); | 47 let st = dart.stackTrace(e); |
| 48 return async.Future$(Isolate).error(e, st); | 48 return $async.Future$(Isolate).error(e, st); |
| 49 } | 49 } |
| 50 | 50 |
| 51 } | 51 } |
| 52 static spawnUri(uri, args, message, opts) { | 52 static spawnUri(uri, args, message, opts) { |
| 53 let paused = opts && 'paused' in opts ? opts.paused : false; | 53 let paused = opts && 'paused' in opts ? opts.paused : false; |
| 54 let packageRoot = opts && 'packageRoot' in opts ? opts.packageRoot : null; | 54 let packageRoot = opts && 'packageRoot' in opts ? opts.packageRoot : null; |
| 55 if (packageRoot != null) dart.throw(new core.UnimplementedError("packageRo
ot")); | 55 if (packageRoot != null) dart.throw(new core.UnimplementedError("packageRo
ot")); |
| 56 try { | 56 try { |
| 57 if (dart.is(args, core.List)) { | 57 if (dart.is(args, core.List)) { |
| 58 for (let i = 0; i < dart.notNull(args[dartx.length]); i++) { | 58 for (let i = 0; i < dart.notNull(args[dartx.length]); i++) { |
| 59 if (!(typeof args[dartx.get](i) == 'string')) { | 59 if (!(typeof args[dartx.get](i) == 'string')) { |
| 60 dart.throw(new core.ArgumentError(`Args must be a list of Strings
${args}`)); | 60 dart.throw(new core.ArgumentError(`Args must be a list of Strings
${args}`)); |
| 61 } | 61 } |
| 62 } | 62 } |
| 63 } else if (args != null) { | 63 } else if (args != null) { |
| 64 dart.throw(new core.ArgumentError(`Args must be a list of Strings ${ar
gs}`)); | 64 dart.throw(new core.ArgumentError(`Args must be a list of Strings ${ar
gs}`)); |
| 65 } | 65 } |
| 66 return _isolate_helper.IsolateNatives.spawnUri(uri, args, message, pause
d).then(dart.fn(msg => new Isolate(dart.as(msg[dartx.get](1), SendPort), {pauseC
apability: dart.as(msg[dartx.get](2), Capability), terminateCapability: dart.as(
msg[dartx.get](3), Capability)}), Isolate, [core.List])); | 66 return _isolate_helper.IsolateNatives.spawnUri(uri, args, message, pause
d).then(dart.fn(msg => new Isolate(dart.as(msg[dartx.get](1), SendPort), {pauseC
apability: dart.as(msg[dartx.get](2), Capability), terminateCapability: dart.as(
msg[dartx.get](3), Capability)}), Isolate, [core.List])); |
| 67 } catch (e) { | 67 } catch (e) { |
| 68 let st = dart.stackTrace(e); | 68 let st = dart.stackTrace(e); |
| 69 return async.Future$(Isolate).error(e, st); | 69 return $async.Future$(Isolate).error(e, st); |
| 70 } | 70 } |
| 71 | 71 |
| 72 } | 72 } |
| 73 pause(resumeCapability) { | 73 pause(resumeCapability) { |
| 74 if (resumeCapability === void 0) resumeCapability = null; | 74 if (resumeCapability === void 0) resumeCapability = null; |
| 75 if (resumeCapability == null) resumeCapability = Capability.new(); | 75 if (resumeCapability == null) resumeCapability = Capability.new(); |
| 76 this[_pause](resumeCapability); | 76 this[_pause](resumeCapability); |
| 77 return resumeCapability; | 77 return resumeCapability; |
| 78 } | 78 } |
| 79 [_pause](resumeCapability) { | 79 [_pause](resumeCapability) { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 get errors() { | 135 get errors() { |
| 136 let controller = null; | 136 let controller = null; |
| 137 let port = null; | 137 let port = null; |
| 138 function handleError(message) { | 138 function handleError(message) { |
| 139 let errorDescription = dart.as(dart.dindex(message, 0), core.String); | 139 let errorDescription = dart.as(dart.dindex(message, 0), core.String); |
| 140 let stackDescription = dart.as(dart.dindex(message, 1), core.String); | 140 let stackDescription = dart.as(dart.dindex(message, 1), core.String); |
| 141 let error = new RemoteError(errorDescription, stackDescription); | 141 let error = new RemoteError(errorDescription, stackDescription); |
| 142 controller.addError(error, error.stackTrace); | 142 controller.addError(error, error.stackTrace); |
| 143 } | 143 } |
| 144 dart.fn(handleError, dart.void, [dart.dynamic]); | 144 dart.fn(handleError, dart.void, [dart.dynamic]); |
| 145 controller = async.StreamController.broadcast({sync: true, onListen: dart.
fn((() => { | 145 controller = $async.StreamController.broadcast({sync: true, onListen: dart
.fn((() => { |
| 146 port = RawReceivePort.new(handleError); | 146 port = RawReceivePort.new(handleError); |
| 147 this.addErrorListener(port.sendPort); | 147 this.addErrorListener(port.sendPort); |
| 148 }).bind(this), dart.void, []), onCancel: dart.fn((() => { | 148 }).bind(this), dart.void, []), onCancel: dart.fn((() => { |
| 149 this.removeErrorListener(port.sendPort); | 149 this.removeErrorListener(port.sendPort); |
| 150 port.close(); | 150 port.close(); |
| 151 port = null; | 151 port = null; |
| 152 }).bind(this), dart.void, [])}); | 152 }).bind(this), dart.void, [])}); |
| 153 return controller.stream; | 153 return controller.stream; |
| 154 } | 154 } |
| 155 } | 155 } |
| 156 dart.setSignature(Isolate, { | 156 dart.setSignature(Isolate, { |
| 157 constructors: () => ({Isolate: [Isolate, [SendPort], {pauseCapability: Capab
ility, terminateCapability: Capability}]}), | 157 constructors: () => ({Isolate: [Isolate, [SendPort], {pauseCapability: Capab
ility, terminateCapability: Capability}]}), |
| 158 methods: () => ({ | 158 methods: () => ({ |
| 159 pause: [Capability, [], [Capability]], | 159 pause: [Capability, [], [Capability]], |
| 160 [_pause]: [dart.void, [Capability]], | 160 [_pause]: [dart.void, [Capability]], |
| 161 resume: [dart.void, [Capability]], | 161 resume: [dart.void, [Capability]], |
| 162 addOnExitListener: [dart.void, [SendPort]], | 162 addOnExitListener: [dart.void, [SendPort]], |
| 163 removeOnExitListener: [dart.void, [SendPort]], | 163 removeOnExitListener: [dart.void, [SendPort]], |
| 164 setErrorsFatal: [dart.void, [core.bool]], | 164 setErrorsFatal: [dart.void, [core.bool]], |
| 165 kill: [dart.void, [], [core.int]], | 165 kill: [dart.void, [], [core.int]], |
| 166 ping: [dart.void, [SendPort], [core.int]], | 166 ping: [dart.void, [SendPort], [core.int]], |
| 167 addErrorListener: [dart.void, [SendPort]], | 167 addErrorListener: [dart.void, [SendPort]], |
| 168 removeErrorListener: [dart.void, [SendPort]] | 168 removeErrorListener: [dart.void, [SendPort]] |
| 169 }), | 169 }), |
| 170 statics: () => ({ | 170 statics: () => ({ |
| 171 spawn: [async.Future$(Isolate), [dart.functionType(dart.void, [dart.dynami
c]), dart.dynamic], {paused: core.bool}], | 171 spawn: [$async.Future$(Isolate), [dart.functionType(dart.void, [dart.dynam
ic]), dart.dynamic], {paused: core.bool}], |
| 172 spawnUri: [async.Future$(Isolate), [core.Uri, core.List$(core.String), dar
t.dynamic], {paused: core.bool, packageRoot: core.Uri}] | 172 spawnUri: [$async.Future$(Isolate), [core.Uri, core.List$(core.String), da
rt.dynamic], {paused: core.bool, packageRoot: core.Uri}] |
| 173 }), | 173 }), |
| 174 names: ['spawn', 'spawnUri'] | 174 names: ['spawn', 'spawnUri'] |
| 175 }); | 175 }); |
| 176 Isolate.IMMEDIATE = 0; | 176 Isolate.IMMEDIATE = 0; |
| 177 Isolate.BEFORE_NEXT_EVENT = 1; | 177 Isolate.BEFORE_NEXT_EVENT = 1; |
| 178 Isolate.AS_EVENT = 2; | 178 Isolate.AS_EVENT = 2; |
| 179 dart.defineLazyProperties(Isolate, { | 179 dart.defineLazyProperties(Isolate, { |
| 180 get _currentIsolateCache() { | 180 get _currentIsolateCache() { |
| 181 return _isolate_helper.IsolateNatives.currentIsolate; | 181 return _isolate_helper.IsolateNatives.currentIsolate; |
| 182 } | 182 } |
| 183 }); | 183 }); |
| 184 class SendPort extends core.Object {} | 184 class SendPort extends core.Object {} |
| 185 SendPort[dart.implements] = () => [Capability]; | 185 SendPort[dart.implements] = () => [Capability]; |
| 186 class ReceivePort extends core.Object { | 186 class ReceivePort extends core.Object { |
| 187 static new() { | 187 static new() { |
| 188 return new _isolate_helper.ReceivePortImpl(); | 188 return new _isolate_helper.ReceivePortImpl(); |
| 189 } | 189 } |
| 190 static fromRawReceivePort(rawPort) { | 190 static fromRawReceivePort(rawPort) { |
| 191 return new _isolate_helper.ReceivePortImpl.fromRawReceivePort(rawPort); | 191 return new _isolate_helper.ReceivePortImpl.fromRawReceivePort(rawPort); |
| 192 } | 192 } |
| 193 } | 193 } |
| 194 ReceivePort[dart.implements] = () => [async.Stream]; | 194 ReceivePort[dart.implements] = () => [$async.Stream]; |
| 195 dart.setSignature(ReceivePort, { | 195 dart.setSignature(ReceivePort, { |
| 196 constructors: () => ({ | 196 constructors: () => ({ |
| 197 new: [ReceivePort, []], | 197 new: [ReceivePort, []], |
| 198 fromRawReceivePort: [ReceivePort, [RawReceivePort]] | 198 fromRawReceivePort: [ReceivePort, [RawReceivePort]] |
| 199 }) | 199 }) |
| 200 }); | 200 }); |
| 201 class RawReceivePort extends core.Object { | 201 class RawReceivePort extends core.Object { |
| 202 static new(handler) { | 202 static new(handler) { |
| 203 if (handler === void 0) handler = null; | 203 if (handler === void 0) handler = null; |
| 204 return new _isolate_helper.RawReceivePortImpl(handler); | 204 return new _isolate_helper.RawReceivePortImpl(handler); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 }); | 250 }); |
| 251 // Exports: | 251 // Exports: |
| 252 exports.Capability = Capability; | 252 exports.Capability = Capability; |
| 253 exports.IsolateSpawnException = IsolateSpawnException; | 253 exports.IsolateSpawnException = IsolateSpawnException; |
| 254 exports.Isolate = Isolate; | 254 exports.Isolate = Isolate; |
| 255 exports.SendPort = SendPort; | 255 exports.SendPort = SendPort; |
| 256 exports.ReceivePort = ReceivePort; | 256 exports.ReceivePort = ReceivePort; |
| 257 exports.RawReceivePort = RawReceivePort; | 257 exports.RawReceivePort = RawReceivePort; |
| 258 exports.RemoteError = RemoteError; | 258 exports.RemoteError = RemoteError; |
| 259 }); | 259 }); |
| OLD | NEW |