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

Unified Diff: mojo/public/dart/mojo/sdk_ext/src/natives.dart

Issue 1411843005: Dart: Removes C++ set for closing handles on an unhandled exception. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 2 months 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 | « mojo/public/dart/mojo/lib/src/handle.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/dart/mojo/sdk_ext/src/natives.dart
diff --git a/mojo/public/dart/mojo/sdk_ext/src/natives.dart b/mojo/public/dart/mojo/sdk_ext/src/natives.dart
index 236069efdcbf3c431f211cf9714c88aab69983a3..a9ec169ab442a9319f3f5bc02182256c3f98dad5 100644
--- a/mojo/public/dart/mojo/sdk_ext/src/natives.dart
+++ b/mojo/public/dart/mojo/sdk_ext/src/natives.dart
@@ -9,13 +9,39 @@ class MojoCoreNatives {
}
class MojoHandleNatives {
- static int register(Object eventStream, int handle)
- native "MojoHandle_Register";
+ static Set<int> _unclosedHandles = new Set<int>();
+
+ static void addUnclosed(int handle) {
+ _unclosedHandles.add(handle);
+ }
+
+ static void removeUnclosed(int handle) {
+ _unclosedHandles.remove(handle);
+ }
+
+ static int registerFinalizer(Object eventStream, int handle)
+ native "MojoHandle_RegisterFinalizer";
+
static int close(int handle) native "MojoHandle_Close";
+
static List wait(int handle, int signals, int deadline)
native "MojoHandle_Wait";
+
static List waitMany(List<int> handles, List<int> signals, int deadline)
native "MojoHandle_WaitMany";
+
+ // Called from the embedder's unhandled exception callback.
+ // Returns the number of successfully closed handles.
+ static int _closeUnclosedHandles() {
+ int count = 0;
+ _unclosedHandles.forEach((h) {
+ if (MojoHandleNatives.close(h) == 0) {
+ count++;
+ }
+ });
+ _unclosedHandles.clear();
+ return count;
+ }
}
class MojoHandleWatcherNatives {
« no previous file with comments | « mojo/public/dart/mojo/lib/src/handle.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698