summaryrefslogtreecommitdiff
path: root/src/node_api.h
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2017-11-17 22:16:43 +0100
committerAnna Henningsen <anna@addaleax.net>2017-11-21 08:33:23 +0100
commit9cf352553576ec3cf003a003da7e236772cd245e (patch)
tree81e135066868794a5d60b732a25e53828f729fa8 /src/node_api.h
parentc0f3bc24de1c88fe8daa74d3520880775a021fee (diff)
downloadandroid-node-v8-9cf352553576ec3cf003a003da7e236772cd245e.tar.gz
android-node-v8-9cf352553576ec3cf003a003da7e236772cd245e.tar.bz2
android-node-v8-9cf352553576ec3cf003a003da7e236772cd245e.zip
n-api: add helper for addons to get the event loop
Add a utility functions for addons to use when they need a reference to the current event loop. While the libuv API is not directly part of N-API, it provides a quite stable C API as well, and is tightly integrated with Node itself. As a particular use case, without access to the event loop it is hard to do something interesting from inside a N-API finalizer function, since calls into JS and therefore virtually all other N-API functions are not allowed. PR-URL: https://github.com/nodejs/node/pull/17109 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'src/node_api.h')
-rw-r--r--src/node_api.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/node_api.h b/src/node_api.h
index a3a07a6467..8e5eef8a47 100644
--- a/src/node_api.h
+++ b/src/node_api.h
@@ -14,6 +14,8 @@
#include <stdbool.h>
#include "node_api_types.h"
+struct uv_loop_s; // Forward declaration.
+
#ifdef _WIN32
#ifdef BUILDING_NODE_EXTENSION
#ifdef EXTERNAL_NAPI
@@ -581,6 +583,10 @@ NAPI_EXTERN napi_status napi_run_script(napi_env env,
napi_value script,
napi_value* result);
+// Return the current libuv event loop for a given environment
+NAPI_EXTERN napi_status napi_get_uv_event_loop(napi_env env,
+ struct uv_loop_s** loop);
+
EXTERN_C_END
#endif // SRC_NODE_API_H_