Skip to content

Commit 2347de8

Browse files
committed
src: inline AsyncCleanupHookHandle in headers
1 parent 4db9854 commit 2347de8

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-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

+10-2
Original file line numberDiff line numberDiff line change
@@ -925,12 +925,20 @@ 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(v8::Isolate* isolate,
933+
void (*fun)(void* arg, void (*cb)(void*), void* cbarg),
934+
void* arg) {
935+
return AsyncCleanupHookHandle(AddEnvironmentCleanupHookRaw(isolate, fun, arg));
936+
}
932937

933-
NODE_EXTERN void RemoveEnvironmentCleanupHook(AsyncCleanupHookHandle holder);
938+
NODE_EXTERN void RemoveEnvironmentCleanupHookRaw(ACHHandle* holder);
939+
inline void RemoveEnvironmentCleanupHook(AsyncCleanupHookHandle holder) {
940+
RemoveEnvironmentCleanupHookRaw(holder.get());
941+
}
934942

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

0 commit comments

Comments
 (0)