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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/lib/isolate.cc ('k') | runtime/vm/bootstrap_natives.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/isolate_patch.dart
diff --git a/runtime/lib/isolate_patch.dart b/runtime/lib/isolate_patch.dart
index 2fd5e4f267a3f9170741f301accacf3bc4c8842e..0946a7732e186632767fcbe2dea0aaeb9c957f62 100644
--- a/runtime/lib/isolate_patch.dart
+++ b/runtime/lib/isolate_patch.dart
@@ -256,6 +256,10 @@ void _startIsolate(SendPort parentPort,
}
patch class Isolate {
+ static final _currentIsolate = _getCurrentIsolate();
+
+ /* patch */ static Isolate get current => _currentIsolate;
+
/* patch */ static Future<Isolate> spawn(
void entryPoint(message), var message, { bool paused: false }) {
// `paused` isn't handled yet.
@@ -379,4 +383,14 @@ patch class Isolate {
/* patch */ void removeErrorListener(SendPort port) {
throw new UnsupportedError("removeErrorListener");
}
+
+ static Isolate _getCurrentIsolate() {
+ List portAndCapabilities = _getPortAndCapabilitiesOfCurrentIsolate();
+ return new Isolate(portAndCapabilities[0],
+ pauseCapability: portAndCapabilities[1],
+ terminateCapability: portAndCapabilities[2]);
+ }
+
+ static List _getPortAndCapabilitiesOfCurrentIsolate()
+ native "Isolate_getPortAndCapabilitiesOfCurrentIsolate";
}
« 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