diff options
author | Gabriel Schulhof <gabriel.schulhof@intel.com> | 2017-08-24 13:33:26 +0300 |
---|---|---|
committer | Gabriel Schulhof <gabriel.schulhof@intel.com> | 2017-08-25 12:02:55 +0300 |
commit | 7efb8f7619100973877c660d0ee527ea3d92de8d (patch) | |
tree | 7b7d9f319f907713d3fa22cfd3d304ebbeeaac63 /src/node_api_types.h | |
parent | 64f59be62fcf55e6d0e7019ee61c712196c6914f (diff) | |
download | android-node-v8-7efb8f7619100973877c660d0ee527ea3d92de8d.tar.gz android-node-v8-7efb8f7619100973877c660d0ee527ea3d92de8d.tar.bz2 android-node-v8-7efb8f7619100973877c660d0ee527ea3d92de8d.zip |
n-api: implement promise
Promise is implemented as a pair of objects. `napi_create_promise()`
returns both a JavaScript promise and a newly allocated "deferred" in
its out-params. The deferred is linked to the promise such that the
deferred can be passed to `napi_resolve_deferred()` or
`napi_reject_deferred()` to reject/resolve the promise.
`napi_is_promise()` can be used to check if a `napi_value` is a native
promise - that is, a promise created by the underlying engine, rather
than a pure JS implementation of a promise.
PR-URL: https://github.com/nodejs/node/pull/14365
Fixes: https://github.com/nodejs/abi-stable-node/issues/242
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Diffstat (limited to 'src/node_api_types.h')
-rw-r--r-- | src/node_api_types.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/node_api_types.h b/src/node_api_types.h index 0bdc377c8f..ac8482bf9d 100644 --- a/src/node_api_types.h +++ b/src/node_api_types.h @@ -17,6 +17,7 @@ typedef struct napi_handle_scope__ *napi_handle_scope; typedef struct napi_escapable_handle_scope__ *napi_escapable_handle_scope; typedef struct napi_callback_info__ *napi_callback_info; typedef struct napi_async_work__ *napi_async_work; +typedef struct napi_deferred__ *napi_deferred; typedef enum { napi_default = 0, |