process.finalization.registerBeforeExit(ref, callback)
稳定性: 1.1 - 处于活跃开发中
ref<Object> | <Function> 正在被跟踪的资源的引用。callback<Function> 资源完成时要调用的回调函数。ref<Object> | <Function> 正在跟踪的资源的引用。event<string> 触发终结的事件。默认值为 'beforeExit'。
此函数的行为与 register 完全相同,唯一不同的是,如果 ref 对象未被垃圾回收,则在进程触发 beforeExit 事件时将调用回调。
【This function behaves exactly like the register, except that the callback will be called
when the process emits the beforeExit event if ref object was not garbage collected.】
请注意,所有适用于 beforeExit 事件的限制也适用于 callback 函数,这意味着在特殊情况下,回调可能不会被调用。
【Be aware that all limitations applied to the beforeExit event are also applied to the callback function,
this means that there is a possibility that the callback will not be called under special circumstances.】