summaryrefslogtreecommitdiff
path: root/test/addons
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2017-11-17 22:13:18 +0100
committerAnna Henningsen <anna@addaleax.net>2017-11-21 08:33:19 +0100
commitc0f3bc24de1c88fe8daa74d3520880775a021fee (patch)
tree26da06a040eb22d16fe6fee354a0c4ddf6527b5b /test/addons
parent804eb3cd734176f123142f0db496279cb2f645fd (diff)
downloadandroid-node-v8-c0f3bc24de1c88fe8daa74d3520880775a021fee.tar.gz
android-node-v8-c0f3bc24de1c88fe8daa74d3520880775a021fee.tar.bz2
android-node-v8-c0f3bc24de1c88fe8daa74d3520880775a021fee.zip
src: 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. Currently, `uv_default_loop()` works if the embedder is the single-threaded default node executable, but even without the presence of e.g. workers that might not really an API guarantee for when Node is embedded. 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 'test/addons')
-rw-r--r--test/addons/async-hello-world/binding.cc2
-rw-r--r--test/addons/callback-scope/binding.cc5
2 files changed, 5 insertions, 2 deletions
diff --git a/test/addons/async-hello-world/binding.cc b/test/addons/async-hello-world/binding.cc
index f773bfffcd..5b3a800709 100644
--- a/test/addons/async-hello-world/binding.cc
+++ b/test/addons/async-hello-world/binding.cc
@@ -77,7 +77,7 @@ void Method(const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::Local<v8::Function> callback = v8::Local<v8::Function>::Cast(args[1]);
req->callback.Reset(isolate, callback);
- uv_queue_work(uv_default_loop(),
+ uv_queue_work(node::GetCurrentEventLoop(isolate),
&req->req,
DoAsync,
(uv_after_work_cb)AfterAsync<use_makecallback>);
diff --git a/test/addons/callback-scope/binding.cc b/test/addons/callback-scope/binding.cc
index f03d8a20d5..34d452bbb7 100644
--- a/test/addons/callback-scope/binding.cc
+++ b/test/addons/callback-scope/binding.cc
@@ -52,7 +52,10 @@ static void TestResolveAsync(const v8::FunctionCallbackInfo<v8::Value>& args) {
uv_work_t* req = new uv_work_t;
- uv_queue_work(uv_default_loop(), req, [](uv_work_t*) {}, Callback);
+ uv_queue_work(node::GetCurrentEventLoop(isolate),
+ req,
+ [](uv_work_t*) {},
+ Callback);
}
v8::Local<v8::Promise::Resolver> local =