Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: inline AsyncCleanupHookHandle in headers #37000

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/api/hooks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ static void RunAsyncCleanupHook(void* arg) {
info->fun(info->arg, FinishAsyncCleanupHook, info);
}

AsyncCleanupHookHandle AddEnvironmentCleanupHook(
ACHHandle* AddEnvironmentCleanupHookInternal(
jasnell marked this conversation as resolved.
Show resolved Hide resolved
Isolate* isolate,
AsyncCleanupHook fun,
void* arg) {
Expand All @@ -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 RemoveEnvironmentCleanupHookInternal(
ACHHandle* handle) {
if (handle->info->started) return;
handle->info->self.reset();
handle->info->env->RemoveCleanupHook(RunAsyncCleanupHook, handle->info.get());
Expand Down
18 changes: 16 additions & 2 deletions src/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -925,12 +925,26 @@ struct ACHHandle;
struct NODE_EXTERN DeleteACHHandle { void operator()(ACHHandle*) const; };
typedef std::unique_ptr<ACHHandle, DeleteACHHandle> AsyncCleanupHookHandle;

NODE_EXTERN AsyncCleanupHookHandle AddEnvironmentCleanupHook(
/* This function is not intended to be used externally, it exists to aid in
* keeping ABI compatibility between Node and Electron. */
NODE_EXTERN ACHHandle* AddEnvironmentCleanupHookInternal(
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(AddEnvironmentCleanupHookInternal(isolate, fun,
arg));
}

NODE_EXTERN void RemoveEnvironmentCleanupHook(AsyncCleanupHookHandle holder);
/* This function is not intended to be used externally, it exists to aid in
* keeping ABI compatibility between Node and Electron. */
NODE_EXTERN void RemoveEnvironmentCleanupHookInternal(ACHHandle* holder);
inline void RemoveEnvironmentCleanupHook(AsyncCleanupHookHandle holder) {
RemoveEnvironmentCleanupHookInternal(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
Expand Down