Skip to content

Commit 77b6298

Browse files
bnoordhuiscodebytere
authored andcommitted
src: remove BeforeExit callback list
It obscures the fact that there is only a single BeforeExit action. Just call that statically from `EmitBeforeExit()`. PR-URL: #33386 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent b599037 commit 77b6298

File tree

3 files changed

+4
-24
lines changed

3 files changed

+4
-24
lines changed

src/api/hooks.cc

+4-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ void AtExit(Environment* env, void (*cb)(void* arg), void* arg) {
3030
}
3131

3232
void EmitBeforeExit(Environment* env) {
33-
env->RunBeforeExitCallbacks();
33+
TraceEventScope trace_scope(TRACING_CATEGORY_NODE1(environment),
34+
"BeforeExit", env);
35+
if (!env->destroy_async_id_list()->empty())
36+
AsyncWrap::DestroyAsyncIdsCallback(env);
3437

3538
HandleScope handle_scope(env->isolate());
3639
Context::Scope context_scope(env->context());

src/env.cc

-20
Original file line numberDiff line numberDiff line change
@@ -366,13 +366,6 @@ Environment::Environment(IsolateData* isolate_data,
366366
}
367367

368368
destroy_async_id_list_.reserve(512);
369-
BeforeExit(
370-
[](void* arg) {
371-
Environment* env = static_cast<Environment*>(arg);
372-
if (!env->destroy_async_id_list()->empty())
373-
AsyncWrap::DestroyAsyncIdsCallback(env);
374-
},
375-
this);
376369

377370
performance_state_ =
378371
std::make_unique<performance::PerformanceState>(isolate());
@@ -640,19 +633,6 @@ void Environment::RunCleanup() {
640633
}
641634
}
642635

643-
void Environment::RunBeforeExitCallbacks() {
644-
TraceEventScope trace_scope(TRACING_CATEGORY_NODE1(environment),
645-
"BeforeExit", this);
646-
for (ExitCallback before_exit : before_exit_functions_) {
647-
before_exit.cb_(before_exit.arg_);
648-
}
649-
before_exit_functions_.clear();
650-
}
651-
652-
void Environment::BeforeExit(void (*cb)(void* arg), void* arg) {
653-
before_exit_functions_.push_back(ExitCallback{cb, arg});
654-
}
655-
656636
void Environment::RunAtExitCallbacks() {
657637
TraceEventScope trace_scope(TRACING_CATEGORY_NODE1(environment),
658638
"AtExit", this);

src/env.h

-3
Original file line numberDiff line numberDiff line change
@@ -1118,8 +1118,6 @@ class Environment : public MemoryRetainer {
11181118
const char* name,
11191119
v8::FunctionCallback callback);
11201120

1121-
void BeforeExit(void (*cb)(void* arg), void* arg);
1122-
void RunBeforeExitCallbacks();
11231121
void AtExit(void (*cb)(void* arg), void* arg);
11241122
void RunAtExitCallbacks();
11251123

@@ -1394,7 +1392,6 @@ class Environment : public MemoryRetainer {
13941392
void (*cb_)(void* arg);
13951393
void* arg_;
13961394
};
1397-
std::list<ExitCallback> before_exit_functions_;
13981395

13991396
std::list<ExitCallback> at_exit_functions_;
14001397

0 commit comments

Comments
 (0)