diff options
author | Anna Henningsen <anna@addaleax.net> | 2019-07-15 22:17:45 +0200 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2019-08-01 00:51:43 +0200 |
commit | 5207dec0175de92116262e8382d6ac57def3a203 (patch) | |
tree | e90e855f7a8a228e00fe0d49fb311b319de74c3d /src/async_wrap.cc | |
parent | 61f3a5c60ad78506e9e0caae061a04ccab878ca1 (diff) | |
download | node-new-5207dec0175de92116262e8382d6ac57def3a203.tar.gz |
src: allow generic C++ callables in SetImmediate()
Modify the native `SetImmediate()` functions to take generic C++
callables as arguments. This makes passing arguments to the callback
easier, and in particular, it allows passing `std::unique_ptr`s
directly, which in turn makes sure that the data they point to is
deleted if the `Environment` is torn down before the callback can run.
PR-URL: https://github.com/nodejs/node/pull/28704
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/async_wrap.cc')
-rw-r--r-- | src/async_wrap.cc | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/async_wrap.cc b/src/async_wrap.cc index 83b661a12d..8410dd2e0d 100644 --- a/src/async_wrap.cc +++ b/src/async_wrap.cc @@ -87,7 +87,7 @@ struct AsyncWrapObject : public AsyncWrap { SET_SELF_SIZE(AsyncWrapObject) }; -void AsyncWrap::DestroyAsyncIdsCallback(Environment* env, void* data) { +void AsyncWrap::DestroyAsyncIdsCallback(Environment* env) { Local<Function> fn = env->async_hooks_destroy_function(); TryCatchScope try_catch(env, TryCatchScope::CatchMode::kFatal); @@ -642,7 +642,7 @@ void AsyncWrap::EmitDestroy(Environment* env, double async_id) { } if (env->destroy_async_id_list()->empty()) { - env->SetUnrefImmediate(DestroyAsyncIdsCallback, nullptr); + env->SetUnrefImmediate(&DestroyAsyncIdsCallback); } env->destroy_async_id_list()->push_back(async_id); |