summaryrefslogtreecommitdiff
path: root/src/node_api.h
diff options
context:
space:
mode:
authorJason Ginchereau <jasongin@microsoft.com>2017-08-26 15:44:43 -0700
committerMichael Dawson <mdawson@devrus.com>2017-09-14 16:05:46 -0400
commit0c258bdc4040fcc4ab590fc80dbcd2182b4c74ae (patch)
tree6e0ea3e5311bb931ebc469d839f3e95226fde06a /src/node_api.h
parent92e5f5cc09fdbf223a418aef1154b2b75b3f9dcd (diff)
downloadandroid-node-v8-0c258bdc4040fcc4ab590fc80dbcd2182b4c74ae.tar.gz
android-node-v8-0c258bdc4040fcc4ab590fc80dbcd2182b4c74ae.tar.bz2
android-node-v8-0c258bdc4040fcc4ab590fc80dbcd2182b4c74ae.zip
n-api: Context for custom async operations
- Add napi_async_context opaque pointer type. (If needed, we could later add APIs for getting the async IDs out of this context.) - Add napi_async_init() and napi_async_destroy() APIs. - Add async_context parameter to napi_make_callback(). - Add code and checks to test_make_callback to validate async context APIs by checking async hooks are called with correct context. - Update API documentation. PR-URL: https://github.com/nodejs/node/pull/15189 Fixes: https://github.com/nodejs/node/issues/13254 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/node_api.h')
-rw-r--r--src/node_api.h24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/node_api.h b/src/node_api.h
index cdc3a6bdb7..c7d5e746f1 100644
--- a/src/node_api.h
+++ b/src/node_api.h
@@ -318,14 +318,6 @@ NAPI_EXTERN napi_status napi_instanceof(napi_env env,
napi_value constructor,
bool* result);
-// Napi version of node::MakeCallback(...)
-NAPI_EXTERN napi_status napi_make_callback(napi_env env,
- napi_value recv,
- napi_value func,
- size_t argc,
- const napi_value* argv,
- napi_value* result);
-
// Methods to work with napi_callbacks
// Gets all callback info in a single call. (Ugly, but faster.)
@@ -535,6 +527,22 @@ NAPI_EXTERN napi_status napi_queue_async_work(napi_env env,
NAPI_EXTERN napi_status napi_cancel_async_work(napi_env env,
napi_async_work work);
+// Methods for custom handling of async operations
+NAPI_EXTERN napi_status napi_async_init(napi_env env,
+ napi_value async_resource,
+ napi_value async_resource_name,
+ napi_async_context* result);
+
+NAPI_EXTERN napi_status napi_async_destroy(napi_env env,
+ napi_async_context async_context);
+
+NAPI_EXTERN napi_status napi_make_callback(napi_env env,
+ napi_async_context async_context,
+ napi_value recv,
+ napi_value func,
+ size_t argc,
+ const napi_value* argv,
+ napi_value* result);
// version management
NAPI_EXTERN napi_status napi_get_version(napi_env env, uint32_t* result);