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

Unified Diff: runtime/include/dart_api.h

Issue 205153002: Auto delete persistent weak handles during finalization after invoking the callback associated with… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 9 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 | « runtime/bin/io_buffer.h ('k') | runtime/lib/typed_data.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/include/dart_api.h
===================================================================
--- runtime/include/dart_api.h (revision 34199)
+++ runtime/include/dart_api.h (working copy)
@@ -209,7 +209,7 @@
typedef struct _Dart_WeakPersistentHandle* Dart_WeakPersistentHandle;
typedef void (*Dart_WeakPersistentHandleFinalizer)(
- Dart_Isolate isolate,
+ void* isolate_callback_data,
Dart_WeakPersistentHandle handle,
void* peer);
typedef void (*Dart_PeerFinalizer)(void* peer);
@@ -435,15 +435,19 @@
/**
* Allocates a weak persistent handle for an object.
*
- * This handle has the lifetime of the current isolate unless it is
- * explicitly deallocated by calling Dart_DeleteWeakPersistentHandle.
+ * This handle has the lifetime of the current isolate unless the object
+ * pointed to by the handle is garbage collected, in this case the VM
+ * automatically deletes the handle after invoking the callback associated
+ * with the handle. The handle can also be explicitly deallocated by
+ * calling Dart_DeleteWeakPersistentHandle.
*
* If the object becomes unreachable the callback is invoked with the weak
* persistent handle and the peer as arguments. This gives the native code the
- * ability to cleanup data associated with the object and to delete the weak
- * persistent handle. It is illegal to call into the VM from the callback,
- * except to delete the weak persistent handle. If the handle is deleted before
- * the object becomes unreachable, the callback is never invoked.
+ * ability to cleanup data associated with the object and clear out any cached
+ * references to the handle. All references to this handle after the callback
+ * will be invalid. It is illegal to call into the VM from the callback.
+ * If the handle is deleted before the object becomes unreachable,
+ * the callback is never invoked.
*
* Requires there to be a current isolate.
*
@@ -454,6 +458,7 @@
* bytes for peer. Used to inform the garbage collector.
* \param callback A function pointer that will be invoked sometime
* after the object is garbage collected, unless the handle has been deleted.
+ * A valid callback needs to be specified it cannot be NULL.
*
* \return Success if the weak persistent handle was
* created. Otherwise, returns an error.
@@ -480,9 +485,20 @@
* epilogue callbacks. During all other garbage collections, prologue
* weak persistent handles strongly reference their referents.
*
- * This handle has the lifetime of the current isolate unless it is
- * explicitly deallocated by calling Dart_DeleteWeakPersistentHandle.
+ * This handle has the lifetime of the current isolate unless the object
+ * pointed to by the handle is garbage collected, in this case the VM
+ * automatically deletes the handle after invoking the callback associated
+ * with the handle. The handle can also be explicitly deallocated by
+ * calling Dart_DeleteWeakPersistentHandle.
*
+ * If the object becomes unreachable the callback is invoked with the weak
+ * persistent handle and the peer as arguments. This gives the native code the
+ * ability to cleanup data associated with the object and clear out any cached
+ * references to the handle. All references to this handle after the callback
+ * will be invalid. It is illegal to call into the VM from the callback.
+ * If the handle is deleted before the object becomes unreachable,
+ * the callback is never invoked.
+ *
* Requires there to be a current isolate.
*
* \param object An object.
@@ -492,6 +508,7 @@
* bytes for peer. Used to inform the garbage collector.
* \param callback A function pointer that will be invoked sometime
* after the object is garbage collected, unless the handle has been deleted.
+ * A valid callback needs to be specified it cannot be NULL.
*
* \return Success if the prologue weak persistent handle was created.
* Otherwise, returns an error.
« no previous file with comments | « runtime/bin/io_buffer.h ('k') | runtime/lib/typed_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698