| 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 {
|
|
|