Skip to content

Commit d1e1dbf

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 de608c3 commit d1e1dbf

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
@@ -373,13 +373,6 @@ Environment::Environment(IsolateData* isolate_data,
373373
}
374374

375375
destroy_async_id_list_.reserve(512);
376-
BeforeExit(
377-
[](void* arg) {
378-
Environment* env = static_cast<Environment*>(arg);
379-
if (!env->destroy_async_id_list()->empty())
380-
AsyncWrap::DestroyAsyncIdsCallback(env);
381-
},
382-
this);
383376

384377
performance_state_ =
385378
std::make_unique<performance::PerformanceState>(isolate());
@@ -677,19 +670,6 @@ void Environment::RunCleanup() {
677670
}
678671
}
679672

680-
void Environment::RunBeforeExitCallbacks() {
681-
TraceEventScope trace_scope(TRACING_CATEGORY_NODE1(environment),
682-
"BeforeExit", this);
683-
for (ExitCallback before_exit : before_exit_functions_) {
684-
before_exit.cb_(before_exit.arg_);
685-
}
686-
before_exit_functions_.clear();
687-
}
688-
689-
void Environment::BeforeExit(void (*cb)(void* arg), void* arg) {
690-
before_exit_functions_.push_back(ExitCallback{cb, arg});
691-
}
692-
693673
void Environment::RunAtExitCallbacks() {
694674
TraceEventScope trace_scope(TRACING_CATEGORY_NODE1(environment),
695675
"AtExit", this);

src/env.h

-3
Original file line numberDiff line numberDiff line change
@@ -1101,8 +1101,6 @@ class Environment : public MemoryRetainer {
11011101
const char* name,
11021102
v8::FunctionCallback callback);
11031103

1104-
void BeforeExit(void (*cb)(void* arg), void* arg);
1105-
void RunBeforeExitCallbacks();
11061104
void AtExit(void (*cb)(void* arg), void* arg);
11071105
void RunAtExitCallbacks();
11081106

@@ -1359,7 +1357,6 @@ class Environment : public MemoryRetainer {
13591357
void (*cb_)(void* arg);
13601358
void* arg_;
13611359
};
1362-
std::list<ExitCallback> before_exit_functions_;
13631360

13641361
std::list<ExitCallback> at_exit_functions_;
13651362

0 commit comments

Comments
 (0)