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

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: 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..699be83f19f95e99300419be7f9335e23f81cb33 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,13 @@ patch class Isolate {
/* patch */ void removeErrorListener(SendPort port) {
throw new UnsupportedError("removeErrorListener");
}
+
+ static Isolate _getCurrentIsolate() {
+ List portAndCapabilities = _getCurrent();
+ return new Isolate(portAndCapabilities[0],
+ pauseCapability: portAndCapabilities[1],
+ terminateCapability: portAndCapabilities[2]);
+ }
+
+ static List _getCurrent() native "Isolate_getCurrent";
floitsch 2014/12/02 12:13:56 s/_getCurrent()/_getPortAndCapabilitiesOfCurrentIs
}

Powered by Google App Engine
This is Rietveld 408576698