Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(224)

Side by Side Diff: sdk/lib/_internal/compiler/implementation/lib/isolate_patch.dart

Issue 11304021: Add NativeEnqueuer to work with the Enqueuer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 void terminate() {} // Nothing useful to do here. 386 void terminate() {} // Nothing useful to do here.
387 } 387 }
388 388
389 /** 389 /**
390 * A stub for interacting with a manager built on a web worker. This 390 * A stub for interacting with a manager built on a web worker. This
391 * definition uses a 'hidden' type (* prefix on the native name) to 391 * definition uses a 'hidden' type (* prefix on the native name) to
392 * enforce that the type is defined dynamically only when web workers 392 * enforce that the type is defined dynamically only when web workers
393 * are actually available. 393 * are actually available.
394 */ 394 */
395 class _WorkerStub implements _ManagerStub native "*Worker" { 395 class _WorkerStub implements _ManagerStub native "*Worker" {
396 get id => JS("Object", "#.id", this); 396 get id => JS("var", "#.id", this);
397 void set id(i) { JS("void", "#.id = #", this, i); } 397 void set id(i) { JS("void", "#.id = #", this, i); }
398 void set onmessage(f) { JS("void", "#.onmessage = #", this, f); } 398 void set onmessage(f) { JS("void", "#.onmessage = #", this, f); }
399 void postMessage(msg) => JS("Object", "#.postMessage(#)", this, msg); 399 void postMessage(msg) => JS("void", "#.postMessage(#)", this, msg);
400 // terminate() is implemented by Worker. 400 // terminate() is implemented by Worker.
401 void terminate(); 401 void terminate();
402 } 402 }
403 403
404 const String _SPAWNED_SIGNAL = "spawned"; 404 const String _SPAWNED_SIGNAL = "spawned";
405 405
406 class _IsolateNatives { 406 class _IsolateNatives {
407 407
408 /** 408 /**
409 * The src url for the script tag that loaded this code. Used to create 409 * The src url for the script tag that loaded this code. Used to create
410 * JavaScript workers. 410 * JavaScript workers.
411 */ 411 */
412 static String get _thisScript => JS("String", r"$thisScriptUrl"); 412 static String get _thisScript => JS("String", r"$thisScriptUrl");
413 413
414 /** Starts a new worker with the given URL. */ 414 /** Starts a new worker with the given URL. */
415 static _WorkerStub _newWorker(url) => JS("Object", r"new Worker(#)", url); 415 static _WorkerStub _newWorker(url) => JS("_WorkerStub", r"new Worker(#)", url) ;
416 416
417 /** 417 /**
418 * Assume that [e] is a browser message event and extract its message data. 418 * Assume that [e] is a browser message event and extract its message data.
419 * We don't import the dom explicitly so, when workers are disabled, this 419 * We don't import the dom explicitly so, when workers are disabled, this
420 * library can also run on top of nodejs. 420 * library can also run on top of nodejs.
421 */ 421 */
422 static _getEventData(e) => JS("Object", "#.data", e); 422 //static _getEventData(e) => JS("Object", "#.data", e);
423 static _getEventData(e) => JS("", "#.data", e);
423 424
424 /** 425 /**
425 * Process messages on a worker, either to control the worker instance or to 426 * Process messages on a worker, either to control the worker instance or to
426 * pass messages along to the isolate running in the worker. 427 * pass messages along to the isolate running in the worker.
427 */ 428 */
428 static void _processWorkerMessage(sender, e) { 429 static void _processWorkerMessage(sender, e) {
429 var msg = _deserializeMessage(_getEventData(e)); 430 var msg = _deserializeMessage(_getEventData(e));
430 switch (msg['command']) { 431 switch (msg['command']) {
431 case 'start': 432 case 'start':
432 _globalState.currentManagerId = msg['id']; 433 _globalState.currentManagerId = msg['id'];
(...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after
1280 _window.clearTimeout(_handle); 1281 _window.clearTimeout(_handle);
1281 } else { 1282 } else {
1282 _window.clearInterval(_handle); 1283 _window.clearInterval(_handle);
1283 } 1284 }
1284 } 1285 }
1285 } 1286 }
1286 1287
1287 Timer _timerFactory(int millis, void callback(Timer timer), bool repeating) => 1288 Timer _timerFactory(int millis, void callback(Timer timer), bool repeating) =>
1288 repeating ? new _Timer.repeating(millis, callback) 1289 repeating ? new _Timer.repeating(millis, callback)
1289 : new _Timer(millis, callback); 1290 : new _Timer(millis, callback);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698