当前 Node.js 环境退出时的清理
¥Cleanup on exit of the current Node.js environment
虽然 Node.js 进程通常会在退出时释放其所有资源,但 Node.js 的嵌入程序或未来的 Worker 支持可能需要插件来注册清理钩子,一旦当前 Node.js 环境退出,这些钩子就会运行。
¥While a Node.js process typically releases all its resources when exiting, embedders of Node.js, or future Worker support, may require addons to register clean-up hooks that will be run once the current Node.js environment exits.
Node-API 提供了注册和取消注册此类回调的功能。当这些回调运行时,插件持有的所有资源都应该被释放。
¥Node-API provides functions for registering and un-registering such callbacks. When those callbacks are run, all resources that are being held by the addon should be freed up.