node_api_nogc_env


稳定性: 1 - 实验性的

¥Stability: 1 - Experimental

napi_env 的这个变体被传递给同步终结器 (node_api_nogc_finalize)。Node-API 的一个子集接受 node_api_nogc_env 类型的参数作为其第一个参数。这些 API 不访问 JavaScript 引擎的状态,因此可以安全地从同步终结器调用。允许将 napi_env 类型的参数传递给这些 API,但是不允许将 node_api_nogc_env 类型的参数传递给访问 JavaScript 引擎状态的 API。当使用标志编译附加组件时,尝试在不进行强制转换的情况下执行此操作将产生编译器警告或错误,这会导致它们在将不正确的指针类型传递到函数时触发警告和/或错误。从同步终结器调用此类 API 最终将导致应用终止。

¥This variant of napi_env is passed to synchronous finalizers (node_api_nogc_finalize). There is a subset of Node-APIs which accept a parameter of type node_api_nogc_env as their first argument. These APIs do not access the state of the JavaScript engine and are thus safe to call from synchronous finalizers. Passing a parameter of type napi_env to these APIs is allowed, however, passing a parameter of type node_api_nogc_env to APIs that access the JavaScript engine state is not allowed. Attempting to do so without a cast will produce a compiler warning or an error when add-ons are compiled with flags which cause them to emit warnings and/or errors when incorrect pointer types are passed into a function. Calling such APIs from a synchronous finalizer will ultimately result in the termination of the application.