Skip to content

Commit 1fe571a

Browse files
implausiblejasnell
authored andcommitted
src: inline AsyncCleanupHookHandle in headers
Fixes: #36349 PR-URL: #37000 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent a87190b commit 1fe571a

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

src/api/hooks.cc

+4-4
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ static void RunAsyncCleanupHook(void* arg) {
145145
info->fun(info->arg, FinishAsyncCleanupHook, info);
146146
}
147147

148-
AsyncCleanupHookHandle AddEnvironmentCleanupHook(
148+
ACHHandle* AddEnvironmentCleanupHookRaw(
149149
Isolate* isolate,
150150
AsyncCleanupHook fun,
151151
void* arg) {
@@ -157,11 +157,11 @@ AsyncCleanupHookHandle AddEnvironmentCleanupHook(
157157
info->arg = arg;
158158
info->self = info;
159159
env->AddCleanupHook(RunAsyncCleanupHook, info.get());
160-
return AsyncCleanupHookHandle(new ACHHandle { info });
160+
return new ACHHandle { info };
161161
}
162162

163-
void RemoveEnvironmentCleanupHook(
164-
AsyncCleanupHookHandle handle) {
163+
void RemoveEnvironmentCleanupHookRaw(
164+
ACHHandle* handle) {
165165
if (handle->info->started) return;
166166
handle->info->self.reset();
167167
handle->info->env->RemoveCleanupHook(RunAsyncCleanupHook, handle->info.get());

src/node.h

+12-2
Original file line numberDiff line numberDiff line change
@@ -925,12 +925,22 @@ struct ACHHandle;
925925
struct NODE_EXTERN DeleteACHHandle { void operator()(ACHHandle*) const; };
926926
typedef std::unique_ptr<ACHHandle, DeleteACHHandle> AsyncCleanupHookHandle;
927927

928-
NODE_EXTERN AsyncCleanupHookHandle AddEnvironmentCleanupHook(
928+
NODE_EXTERN ACHHandle* AddEnvironmentCleanupHookRaw(
929929
v8::Isolate* isolate,
930930
void (*fun)(void* arg, void (*cb)(void*), void* cbarg),
931931
void* arg);
932+
inline AsyncCleanupHookHandle AddEnvironmentCleanupHook(
933+
v8::Isolate* isolate,
934+
void (*fun)(void* arg, void (*cb)(void*), void* cbarg),
935+
void* arg) {
936+
return AsyncCleanupHookHandle(AddEnvironmentCleanupHookRaw(isolate, fun,
937+
arg));
938+
}
932939

933-
NODE_EXTERN void RemoveEnvironmentCleanupHook(AsyncCleanupHookHandle holder);
940+
NODE_EXTERN void RemoveEnvironmentCleanupHookRaw(ACHHandle* holder);
941+
inline void RemoveEnvironmentCleanupHook(AsyncCleanupHookHandle holder) {
942+
RemoveEnvironmentCleanupHookRaw(holder.get());
943+
}
934944

935945
/* Returns the id of the current execution context. If the return value is
936946
* zero then no execution has been set. This will happen if the user handles

0 commit comments

Comments
 (0)