src: inline AsyncCleanupHookHandle in headers

Fixes: https://github.com/nodejs/node/issues/36349

PR-URL: https://github.com/nodejs/node/pull/37000
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Tyler Ang-Wanek authored and James M Snell committed 2021-01-24 11:12:03 -08:00
1 parent a87190b00c
commit 1fe571aa0c
2 files changed
+16 -6

No files matched your search

+4 -4
View File
@@ -145,7 +145,7 @@ static void RunAsyncCleanupHook(void* arg) {
info->fun(info->arg, FinishAsyncCleanupHook, info);
}
AsyncCleanupHookHandle AddEnvironmentCleanupHook(
ACHHandle* AddEnvironmentCleanupHookRaw(
Isolate* isolate,
AsyncCleanupHook fun,
void* arg) {
@@ -157,11 +157,11 @@ AsyncCleanupHookHandle AddEnvironmentCleanupHook(
info->arg = arg;
info->self = info;
env->AddCleanupHook(RunAsyncCleanupHook, info.get());
return AsyncCleanupHookHandle(new ACHHandle { info });
return new ACHHandle { info };
}
void RemoveEnvironmentCleanupHook(
AsyncCleanupHookHandle handle) {
void RemoveEnvironmentCleanupHookRaw(
ACHHandle* handle) {
if (handle->info->started) return;
handle->info->self.reset();
handle->info->env->RemoveCleanupHook(RunAsyncCleanupHook, handle->info.get());
+12 -2
View File
@@ -925,12 +925,22 @@ struct ACHHandle;
struct NODE_EXTERN DeleteACHHandle { void operator()(ACHHandle*) const; };
typedef std::unique_ptr<ACHHandle, DeleteACHHandle> AsyncCleanupHookHandle;
NODE_EXTERN AsyncCleanupHookHandle AddEnvironmentCleanupHook(
NODE_EXTERN ACHHandle* AddEnvironmentCleanupHookRaw(
v8::Isolate* isolate,
void (*fun)(void* arg, void (*cb)(void*), void* cbarg),
void* arg);
inline AsyncCleanupHookHandle AddEnvironmentCleanupHook(
v8::Isolate* isolate,
void (*fun)(void* arg, void (*cb)(void*), void* cbarg),
void* arg) {
return AsyncCleanupHookHandle(AddEnvironmentCleanupHookRaw(isolate, fun,
arg));
}
NODE_EXTERN void RemoveEnvironmentCleanupHook(AsyncCleanupHookHandle holder);
NODE_EXTERN void RemoveEnvironmentCleanupHookRaw(ACHHandle* holder);
inline void RemoveEnvironmentCleanupHook(AsyncCleanupHookHandle holder) {
RemoveEnvironmentCleanupHookRaw(holder.get());
}
/* Returns the id of the current execution context. If the return value is
* zero then no execution has been set. This will happen if the user handles