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

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: Address comments 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
Index: runtime/lib/isolate_patch.dart
diff --git a/runtime/lib/isolate_patch.dart b/runtime/lib/isolate_patch.dart
index 1313609002de2d77afab21a30c262f499610bcf0..eb88de61913ad044aeae36d32dfe8c608ae980b1 100644
--- a/runtime/lib/isolate_patch.dart
+++ b/runtime/lib/isolate_patch.dart
@@ -17,6 +17,8 @@ patch class Capability {
class _CapabilityImpl implements Capability {
factory _CapabilityImpl() native "CapabilityImpl_factory";
+
+ String toString() => "Capability#";
}
patch class RawReceivePort {
@@ -245,6 +247,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.
@@ -368,4 +374,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";
}

Powered by Google App Engine
This is Rietveld 408576698