pub unsafe extern "C" fn Dart_NewWeakPersistentHandle(
    object: Dart_Handle,
    peer: *mut c_void,
    external_allocation_size: isize,
    callback: Dart_HandleFinalizer
) -> Dart_WeakPersistentHandle
Expand description

Allocates a weak persistent handle for an object.

This handle has the lifetime of the current isolate. The handle can also be explicitly deallocated by calling Dart_DeleteWeakPersistentHandle.

If the object becomes unreachable the callback is invoked with the peer as argument. The callback can be executed on any thread, will have a current isolate group, but will not have a current isolate. The callback can only call Dart_DeletePersistentHandle or Dart_DeleteWeakPersistentHandle. This gives the embedder the ability to cleanup data associated with the object. The handle will point to the Dart_Null object after the finalizer has been run. It is illegal to call into the VM with any other Dart_* functions 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 with identity. \param peer A pointer to a native object or NULL. This value is provided to callback when it is invoked. \param external_allocation_size The number of externally allocated 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 The weak persistent handle or NULL. NULL is returned in case of bad parameters.