| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 var isolate$current = null; | 5 var isolate$current = null; |
| 6 var isolate$rootIsolate = null; // Will only be set in the main worker. | 6 var isolate$rootIsolate = null; // Will only be set in the main worker. |
| 7 var isolate$inits = []; | 7 var isolate$inits = []; |
| 8 var isolate$globalThis = this; | 8 var isolate$globalThis = this; |
| 9 | 9 |
| 10 // These declarations are needed to avoid errors from the Closure Compiler | 10 // These declarations are needed to avoid errors from the Closure Compiler |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 function native_IsolateNatives__spawn(runnable, light, replyPort) { | 294 function native_IsolateNatives__spawn(runnable, light, replyPort) { |
| 295 // TODO(floitsch): throw exception if runnable's class doesn't have a | 295 // TODO(floitsch): throw exception if runnable's class doesn't have a |
| 296 // default constructor. | 296 // default constructor. |
| 297 if (isolate$useWorkers && !light) { | 297 if (isolate$useWorkers && !light) { |
| 298 isolate$startWorker(runnable, replyPort); | 298 isolate$startWorker(runnable, replyPort); |
| 299 } else { | 299 } else { |
| 300 isolate$startNonWorker(runnable, replyPort); | 300 isolate$startNonWorker(runnable, replyPort); |
| 301 } | 301 } |
| 302 } | 302 } |
| 303 | 303 |
| 304 function native_IsolateNatives_bind(fn) { | |
| 305 var isolate = isolate$current; | |
| 306 return function() { | |
| 307 var self = this; | |
| 308 var args = arguments; | |
| 309 isolate.run(function() { | |
| 310 fn.apply(self, args); | |
| 311 }); | |
| 312 isolate$runEventLoop(); | |
| 313 }; | |
| 314 } | |
| 315 | |
| 316 function isolate$startNonWorker(runnable, replyTo) { | 304 function isolate$startNonWorker(runnable, replyTo) { |
| 317 // Spawn a new isolate and create the receive port in it. | 305 // Spawn a new isolate and create the receive port in it. |
| 318 var spawned = new isolate$Isolate(); | 306 var spawned = new isolate$Isolate(); |
| 319 | 307 |
| 320 // Instead of just running the provided runnable, we create a | 308 // Instead of just running the provided runnable, we create a |
| 321 // new cloned instance of it with a fresh state in the spawned | 309 // new cloned instance of it with a fresh state in the spawned |
| 322 // isolate. This way, we do not get cross-isolate references | 310 // isolate. This way, we do not get cross-isolate references |
| 323 // through the runnable. | 311 // through the runnable. |
| 324 var factory = runnable.getIsolateFactory(); | 312 var factory = runnable.getIsolateFactory(); |
| 325 isolate$IsolateEvent.enqueue(spawned, function() { | 313 isolate$IsolateEvent.enqueue(spawned, function() { |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 } | 507 } |
| 520 | 508 |
| 521 function isolate$deserializeMessage(message) { | 509 function isolate$deserializeMessage(message) { |
| 522 if (isolate$useWorkers || isolate$useWorkerSerializationProtocol) { | 510 if (isolate$useWorkers || isolate$useWorkerSerializationProtocol) { |
| 523 return native__IsolateJsUtil__deserializeMessage(message); | 511 return native__IsolateJsUtil__deserializeMessage(message); |
| 524 } else { | 512 } else { |
| 525 // Nothing more to do. | 513 // Nothing more to do. |
| 526 return message; | 514 return message; |
| 527 } | 515 } |
| 528 } | 516 } |
| OLD | NEW |