@@ -244,8 +244,9 @@ typedef struct _Dart_IsolateGroup* Dart_IsolateGroup;
244
244
* the object is garbage collected. It is never safe to use these handles
245
245
* unless you know the object is still reachable.
246
246
*
247
- * WeakPersistentHandles are persistent handles which are auto deleted
248
- * when the object is garbage collected.
247
+ * WeakPersistentHandles are persistent handles which are automatically set
248
+ * to point Dart_Null when the object is garbage collected. They are not auto
249
+ * deleted, so it is safe to use them after the object has become unreachable.
249
250
*/
250
251
typedef struct _Dart_Handle * Dart_Handle ;
251
252
typedef Dart_Handle Dart_PersistentHandle ;
@@ -254,10 +255,6 @@ typedef struct _Dart_FinalizableHandle* Dart_FinalizableHandle;
254
255
// These structs are versioned by DART_API_DL_MAJOR_VERSION, bump the
255
256
// version when changing this struct.
256
257
257
- typedef void (* Dart_WeakPersistentHandleFinalizer )(
258
- void * isolate_callback_data ,
259
- Dart_WeakPersistentHandle handle ,
260
- void * peer );
261
258
typedef void (* Dart_HandleFinalizer )(void * isolate_callback_data , void * peer );
262
259
263
260
/**
@@ -423,6 +420,8 @@ DART_EXPORT Dart_Handle Dart_HandleFromPersistent(Dart_PersistentHandle object);
423
420
424
421
/**
425
422
* Allocates a handle in the current scope from a weak persistent handle.
423
+ *
424
+ * This will be a handle to Dart_Null if the object has been garbage collected.
426
425
*/
427
426
DART_EXPORT Dart_Handle
428
427
Dart_HandleFromWeakPersistent (Dart_WeakPersistentHandle object );
@@ -461,24 +460,18 @@ DART_EXPORT void Dart_DeletePersistentHandle(Dart_PersistentHandle object);
461
460
/**
462
461
* Allocates a weak persistent handle for an object.
463
462
*
464
- * This handle has the lifetime of the current isolate unless the object
465
- * pointed to by the handle is garbage collected, in this case the VM
466
- * automatically deletes the handle after invoking the callback associated
467
- * with the handle. The handle can also be explicitly deallocated by
468
- * calling Dart_DeleteWeakPersistentHandle.
469
- *
470
- * If the object becomes unreachable the callback is invoked with the weak
471
- * persistent handle and the peer as arguments. The callback can be executed on
472
- * any thread, will have an isolate group, but will not have a current isolate.
473
- * The callback can only call Dart_DeletePersistentHandle or
474
- * Dart_DeleteWeakPersistentHandle. The callback must not call
475
- * Dart_DeleteWeakPersistentHandle for the handle being finalized, as it is
476
- * automatically deleted by the VM after the callback returns. This gives the
477
- * embedder the ability to cleanup data associated with the object and clear
478
- * out any cached references to the handle. All references to this handle after
479
- * the callback will be invalid. It is illegal to call into the VM with any
480
- * other Dart_* functions from the callback. If the handle is deleted before
481
- * the object becomes unreachable, the callback is never invoked.
463
+ * This handle has the lifetime of the current isolate. The handle can also be
464
+ * explicitly deallocated by calling Dart_DeleteWeakPersistentHandle.
465
+ *
466
+ * If the object becomes unreachable the callback is invoked with the peer as
467
+ * argument. The callback can be executed on any thread, will have a current
468
+ * isolate group, but will not have a current isolate. The callback can only
469
+ * call Dart_DeletePersistentHandle or Dart_DeleteWeakPersistentHandle. This
470
+ * gives the embedder the ability to cleanup data associated with the object.
471
+ * The handle will point to the Dart_Null object after the finalizer has been
472
+ * run. It is illegal to call into the VM with any other Dart_* functions from
473
+ * the callback. If the handle is deleted before the object becomes
474
+ * unreachable, the callback is never invoked.
482
475
*
483
476
* Requires there to be a current isolate.
484
477
*
@@ -498,7 +491,7 @@ DART_EXPORT Dart_WeakPersistentHandle
498
491
Dart_NewWeakPersistentHandle (Dart_Handle object ,
499
492
void * peer ,
500
493
intptr_t external_allocation_size ,
501
- Dart_WeakPersistentHandleFinalizer callback );
494
+ Dart_HandleFinalizer callback );
502
495
503
496
/**
504
497
* Deletes the given weak persistent [object] handle.
@@ -2046,7 +2039,7 @@ Dart_NewExternalLatin1String(const uint8_t* latin1_array,
2046
2039
intptr_t length ,
2047
2040
void * peer ,
2048
2041
intptr_t external_allocation_size ,
2049
- Dart_WeakPersistentHandleFinalizer callback );
2042
+ Dart_HandleFinalizer callback );
2050
2043
2051
2044
/**
2052
2045
* Returns a String which references an external array of UTF-16 encoded
@@ -2067,7 +2060,7 @@ Dart_NewExternalUTF16String(const uint16_t* utf16_array,
2067
2060
intptr_t length ,
2068
2061
void * peer ,
2069
2062
intptr_t external_allocation_size ,
2070
- Dart_WeakPersistentHandleFinalizer callback );
2063
+ Dart_HandleFinalizer callback );
2071
2064
2072
2065
/**
2073
2066
* Gets the C string representation of a String.
@@ -2440,13 +2433,13 @@ DART_EXPORT Dart_Handle Dart_NewExternalTypedData(Dart_TypedData_Type type,
2440
2433
* \return The TypedData object if no error occurs. Otherwise returns
2441
2434
* an error handle.
2442
2435
*/
2443
- DART_EXPORT Dart_Handle Dart_NewExternalTypedDataWithFinalizer (
2444
- Dart_TypedData_Type type ,
2445
- void * data ,
2446
- intptr_t length ,
2447
- void * peer ,
2448
- intptr_t external_allocation_size ,
2449
- Dart_WeakPersistentHandleFinalizer callback );
2436
+ DART_EXPORT Dart_Handle
2437
+ Dart_NewExternalTypedDataWithFinalizer ( Dart_TypedData_Type type ,
2438
+ void * data ,
2439
+ intptr_t length ,
2440
+ void * peer ,
2441
+ intptr_t external_allocation_size ,
2442
+ Dart_HandleFinalizer callback );
2450
2443
2451
2444
/**
2452
2445
* Returns a ByteBuffer object for the typed data.
0 commit comments