Node.js N-API napi_create_async_work

🌙
手机阅读
本文目录结构

Node.js N-API napi_create_async_work

版本历史 版本 变更 v8.6.0 Added async_resource and async_resource_name parameters.

v8.0.0 新增于: v8.0.0

N-API version: 1 napi_status napi_create_async_work(napi_env env, napi_value async_resource, napi_value async_resource_name, napi_async_execute_callback execute, napi_async_complete_callback complete, void* data, napi_async_work* result); [in] env: The environment that the API is invoked under. [in] async_resource: An optional object associated with the async work that will be passed to possible async_hooks init hooks. [in] async_resource_name: Identifier for the kind of resource that is being provided for diagnostic information exposed by the async_hooks API. [in] execute: The native function which should be called to execute the logic asynchronously. The given function is called from a worker pool thread and can execute in parallel with the main event loop thread. [in] complete: The native function which will be called when the asynchronous logic is completed or is cancelled. The given function is called from the main event loop thread. [in] data: User-provided data context. This will be passed back into the execute and complete functions. [out] result: napi_async_work* which is the handle to the newly created async work. Returns napi_ok if the API succeeded.

This API allocates a work object that is used to execute logic asynchronously. It should be freed using napi_delete_async_work once the work is no longer required.

async_resource_name should be a null-terminated, UTF-8-encoded string.

The async_resource_name identifier is provided by the user and should be representative of the type of async work being performed. It is also recommended to apply namespacing to the identifier, e.g. by including the module name. See the async_hooks documentation for more information.


更多内容请参考:Node.js N-API,或者通过 点击对应菜单 进行查看;



AXIHE / 精选资源

浏览全部教程

面试题

学习网站

前端培训
自己甄别

前端书籍

关于朱安邦

我叫 朱安邦,阿西河的站长,在杭州。

以前是一名平面设计师,后来开始接接触前端开发,主要研究前端技术中的JS方向。

业余时间我喜欢分享和交流自己的技术,欢迎大家关注我的 Bilibili

关注我: Github / 知乎

目前重心已经放在研究区块链上面了

我叫朱安邦,阿西河的站长

目前在杭州从事区块链周边的开发工作,机械专业,以前从事平面设计工作。

2014年底脱产在老家自学6个月的前端技术,自学期间几乎从未出过家门,最终找到了满意的前端工作。更多>