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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 topEventLoop = new _EventLoop(); | 181 topEventLoop = new _EventLoop(); |
182 isolates = new Map<int, _IsolateContext>(); | 182 isolates = new Map<int, _IsolateContext>(); |
183 managers = new Map<int, _ManagerStub>(); | 183 managers = new Map<int, _ManagerStub>(); |
184 if (isWorker) { // "if we are not the main manager ourself" is the intent. | 184 if (isWorker) { // "if we are not the main manager ourself" is the intent. |
185 mainManager = new _MainManagerStub(); | 185 mainManager = new _MainManagerStub(); |
186 _nativeInitWorkerMessageHandler(); | 186 _nativeInitWorkerMessageHandler(); |
187 } | 187 } |
188 } | 188 } |
189 | 189 |
190 void _nativeDetectEnvironment() { | 190 void _nativeDetectEnvironment() { |
191 JS("void", r"#.isWorker = $isWorker", this); | 191 isWorker = JS("bool", r"$isWorker"); |
192 JS("void", r"#.supportsWorkers = $supportsWorkers", this); | 192 supportsWorkers = JS("bool", r"$supportsWorkers"); |
193 JS("void", r"#.fromCommandLine = typeof(window) == 'undefined'", this); | 193 fromCommandLine = JS("bool", r"typeof(window) == 'undefined'"); |
194 } | 194 } |
195 | 195 |
196 void _nativeInitWorkerMessageHandler() { | 196 void _nativeInitWorkerMessageHandler() { |
197 JS("void", r""" | 197 JS("void", r""" |
198 $globalThis.onmessage = function (e) { | 198 $globalThis.onmessage = function (e) { |
199 _IsolateNatives._processWorkerMessage(this.mainManager, e); | 199 _IsolateNatives._processWorkerMessage(this.mainManager, e); |
200 }"""); | 200 }"""); |
201 } | 201 } |
202 /*: TODO: check that _processWorkerMessage is not discarded while treeshaking. | 202 /*: TODO: check that _processWorkerMessage is not discarded while treeshaking. |
203 """ { | 203 """ { |
(...skipping 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1281 _window.clearTimeout(_handle); | 1281 _window.clearTimeout(_handle); |
1282 } else { | 1282 } else { |
1283 _window.clearInterval(_handle); | 1283 _window.clearInterval(_handle); |
1284 } | 1284 } |
1285 } | 1285 } |
1286 } | 1286 } |
1287 | 1287 |
1288 Timer _timerFactory(int millis, void callback(Timer timer), bool repeating) => | 1288 Timer _timerFactory(int millis, void callback(Timer timer), bool repeating) => |
1289 repeating ? new _Timer.repeating(millis, callback) | 1289 repeating ? new _Timer.repeating(millis, callback) |
1290 : new _Timer(millis, callback); | 1290 : new _Timer(millis, callback); |
OLD | NEW |