Skip to content

Commit 8ddb6aa

Browse files
bnoordhuisBridgeAR
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 a3f47b1 commit 8ddb6aa

File tree

3 files changed

+4
-24
lines changed

3 files changed

+4
-24
lines changed

src/api/hooks.cc

Lines changed: 4 additions & 1 deletion
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

Lines changed: 0 additions & 20 deletions
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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,8 +1103,6 @@ class Environment : public MemoryRetainer {
11031103
const char* name,
11041104
v8::FunctionCallback callback);
11051105

1106-
void BeforeExit(void (*cb)(void* arg), void* arg);
1107-
void RunBeforeExitCallbacks();
11081106
void AtExit(void (*cb)(void* arg), void* arg);
11091107
void RunAtExitCallbacks();
11101108

@@ -1362,7 +1360,6 @@ class Environment : public MemoryRetainer {
13621360
void (*cb_)(void* arg);
13631361
void* arg_;
13641362
};
1365-
std::list<ExitCallback> before_exit_functions_;
13661363

13671364
std::list<ExitCallback> at_exit_functions_;
13681365

0 commit comments

Comments
 (0)