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

Side by Side Diff: runtime/lib/isolate_patch.dart

Issue 771993003: Add Isolate.current getter, returning the current isolate as an Isolate object. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add test Created 6 years 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
« no previous file with comments | « runtime/lib/isolate.cc ('k') | runtime/vm/bootstrap_natives.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 import "dart:collection" show HashMap; 5 import "dart:collection" show HashMap;
6 6
7 patch class ReceivePort { 7 patch class ReceivePort {
8 /* patch */ factory ReceivePort() = _ReceivePortImpl; 8 /* patch */ factory ReceivePort() = _ReceivePortImpl;
9 9
10 /* patch */ factory ReceivePort.fromRawReceivePort(RawReceivePort rawPort) = 10 /* patch */ factory ReceivePort.fromRawReceivePort(RawReceivePort rawPort) =
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 } else { 249 } else {
250 entryPoint(); 250 entryPoint();
251 } 251 }
252 } else { 252 } else {
253 entryPoint(message); 253 entryPoint(message);
254 } 254 }
255 _runPendingImmediateCallback(); 255 _runPendingImmediateCallback();
256 } 256 }
257 257
258 patch class Isolate { 258 patch class Isolate {
259 static final _currentIsolate = _getCurrentIsolate();
260
261 /* patch */ static Isolate get current => _currentIsolate;
262
259 /* patch */ static Future<Isolate> spawn( 263 /* patch */ static Future<Isolate> spawn(
260 void entryPoint(message), var message, { bool paused: false }) { 264 void entryPoint(message), var message, { bool paused: false }) {
261 // `paused` isn't handled yet. 265 // `paused` isn't handled yet.
262 RawReceivePort readyPort; 266 RawReceivePort readyPort;
263 try { 267 try {
264 // The VM will invoke [_startIsolate] with entryPoint as argument. 268 // The VM will invoke [_startIsolate] with entryPoint as argument.
265 readyPort = new RawReceivePort(); 269 readyPort = new RawReceivePort();
266 _spawnFunction(readyPort.sendPort, entryPoint, message); 270 _spawnFunction(readyPort.sendPort, entryPoint, message);
267 Completer completer = new Completer<Isolate>.sync(); 271 Completer completer = new Completer<Isolate>.sync();
268 readyPort.handler = (readyMessage) { 272 readyPort.handler = (readyMessage) {
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 throw new UnsupportedError("ping"); 376 throw new UnsupportedError("ping");
373 } 377 }
374 378
375 /* patch */ void addErrorListener(SendPort port) { 379 /* patch */ void addErrorListener(SendPort port) {
376 throw new UnsupportedError("addErrorListener"); 380 throw new UnsupportedError("addErrorListener");
377 } 381 }
378 382
379 /* patch */ void removeErrorListener(SendPort port) { 383 /* patch */ void removeErrorListener(SendPort port) {
380 throw new UnsupportedError("removeErrorListener"); 384 throw new UnsupportedError("removeErrorListener");
381 } 385 }
386
387 static Isolate _getCurrentIsolate() {
388 List portAndCapabilities = _getPortAndCapabilitiesOfCurrentIsolate();
389 return new Isolate(portAndCapabilities[0],
390 pauseCapability: portAndCapabilities[1],
391 terminateCapability: portAndCapabilities[2]);
392 }
393
394 static List _getPortAndCapabilitiesOfCurrentIsolate()
395 native "Isolate_getPortAndCapabilitiesOfCurrentIsolate";
382 } 396 }
OLDNEW
« no previous file with comments | « runtime/lib/isolate.cc ('k') | runtime/vm/bootstrap_natives.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698