napi_finalize
附加组件的函数指针类型提供的函数允许用户在外部拥有的数据准备好清理时收到通知,因为与其关联的对象已被垃圾收集。用户必须提供满足以下签名的函数,该函数将在对象的集合上调用。目前,napi_finalize
可用于查明何时收集具有外部数据的对象。
¥Function pointer type for add-on provided functions that allow the user to be
notified when externally-owned data is ready to be cleaned up because the
object with which it was associated with, has been garbage-collected. The user
must provide a function satisfying the following signature which would get
called upon the object's collection. Currently, napi_finalize
can be used for
finding out when objects that have external data are collected.
typedef void (*napi_finalize)(napi_env env,
void* finalize_data,
void* finalize_hint);
除非出于 对象生命周期管理 中讨论的原因,否则无需在函数体内创建句柄和/或回调范围。
¥Unless for reasons discussed in Object Lifetime Management, creating a handle and/or callback scope inside the function body is not necessary.