| OLD | NEW |
| 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 // Patch file for the dart:isolate library. | 5 // Patch file for the dart:isolate library. |
| 6 | 6 |
| 7 #import("dart:uri"); | 7 #import("dart:uri"); |
| 8 | 8 |
| 9 /** | 9 /** |
| 10 * Called by the compiler to support switching | 10 * Called by the compiler to support switching |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 patch ReceivePort get port { | 99 patch ReceivePort get port { |
| 100 if (_lazyPort == null) { | 100 if (_lazyPort == null) { |
| 101 _lazyPort = new ReceivePort(); | 101 _lazyPort = new ReceivePort(); |
| 102 } | 102 } |
| 103 return _lazyPort; | 103 return _lazyPort; |
| 104 } | 104 } |
| 105 | 105 |
| 106 patch SendPort spawnFunction(void topLevelFunction()) { | 106 patch SendPort spawnFunction(void topLevelFunction()) { |
| 107 final name = _IsolateNatives._getJSFunctionName(topLevelFunction); | 107 final name = _IsolateNatives._getJSFunctionName(topLevelFunction); |
| 108 if (name == null) { | 108 if (name == null) { |
| 109 throw new UnsupportedOperationException( | 109 throw new UnsupportedError( |
| 110 "only top-level functions can be spawned."); | 110 "only top-level functions can be spawned."); |
| 111 } | 111 } |
| 112 return _IsolateNatives._spawn(name, null, false); | 112 return _IsolateNatives._spawn(name, null, false); |
| 113 } | 113 } |
| 114 | 114 |
| 115 patch SendPort spawnUri(String uri) { | 115 patch SendPort spawnUri(String uri) { |
| 116 return _IsolateNatives._spawn(null, uri, false); | 116 return _IsolateNatives._spawn(null, uri, false); |
| 117 } | 117 } |
| 118 | 118 |
| 119 /** State associated with the current manager. See [globalState]. */ | 119 /** State associated with the current manager. See [globalState]. */ |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 'uri': uri, | 554 'uri': uri, |
| 555 'replyPort': replyPort})); | 555 'replyPort': replyPort})); |
| 556 } else { | 556 } else { |
| 557 _spawnWorker(functionName, uri, replyPort); | 557 _spawnWorker(functionName, uri, replyPort); |
| 558 } | 558 } |
| 559 } | 559 } |
| 560 | 560 |
| 561 static SendPort _startNonWorker( | 561 static SendPort _startNonWorker( |
| 562 String functionName, String uri, SendPort replyPort) { | 562 String functionName, String uri, SendPort replyPort) { |
| 563 // TODO(eub): support IE9 using an iframe -- Dart issue 1702. | 563 // TODO(eub): support IE9 using an iframe -- Dart issue 1702. |
| 564 if (uri != null) throw new UnsupportedOperationException( | 564 if (uri != null) throw new UnsupportedError( |
| 565 "Currently spawnUri is not supported without web workers."); | 565 "Currently spawnUri is not supported without web workers."); |
| 566 _globalState.topEventLoop.enqueue(new _IsolateContext(), function() { | 566 _globalState.topEventLoop.enqueue(new _IsolateContext(), function() { |
| 567 final func = _getJSFunctionFromName(functionName); | 567 final func = _getJSFunctionFromName(functionName); |
| 568 _startIsolate(func, replyPort); | 568 _startIsolate(func, replyPort); |
| 569 }, 'nonworker start'); | 569 }, 'nonworker start'); |
| 570 } | 570 } |
| 571 | 571 |
| 572 static void _startIsolate(Function topLevel, SendPort replyTo) { | 572 static void _startIsolate(Function topLevel, SendPort replyTo) { |
| 573 _fillStatics(_globalState.currentContext); | 573 _fillStatics(_globalState.currentContext); |
| 574 _lazyPort = new ReceivePort(); | 574 _lazyPort = new ReceivePort(); |
| (...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1280 _window.clearTimeout(_handle); | 1280 _window.clearTimeout(_handle); |
| 1281 } else { | 1281 } else { |
| 1282 _window.clearInterval(_handle); | 1282 _window.clearInterval(_handle); |
| 1283 } | 1283 } |
| 1284 } | 1284 } |
| 1285 } | 1285 } |
| 1286 | 1286 |
| 1287 Timer _timerFactory(int millis, void callback(Timer timer), bool repeating) => | 1287 Timer _timerFactory(int millis, void callback(Timer timer), bool repeating) => |
| 1288 repeating ? new _Timer.repeating(millis, callback) | 1288 repeating ? new _Timer.repeating(millis, callback) |
| 1289 : new _Timer(millis, callback); | 1289 : new _Timer(millis, callback); |
| OLD | NEW |