Skip to content

Commit 3701e5d

Browse files
danbevtargos
authored andcommitted
src: add typedef for CleanupHookCallback callback
This commit adds a typedef for the callback parameter used in CleanupHookCallback's constructor, AddCleanupHook, and RemoveCleanupHook. PR-URL: #36442 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent 9ccf7db commit 3701e5d

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/env-inl.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1041,15 +1041,15 @@ inline void Environment::SetInstanceMethod(v8::Local<v8::FunctionTemplate> that,
10411041
t->SetClassName(name_string);
10421042
}
10431043

1044-
void Environment::AddCleanupHook(void (*fn)(void*), void* arg) {
1044+
void Environment::AddCleanupHook(CleanupCallback fn, void* arg) {
10451045
auto insertion_info = cleanup_hooks_.emplace(CleanupHookCallback {
10461046
fn, arg, cleanup_hook_counter_++
10471047
});
10481048
// Make sure there was no existing element with these values.
10491049
CHECK_EQ(insertion_info.second, true);
10501050
}
10511051

1052-
void Environment::RemoveCleanupHook(void (*fn)(void*), void* arg) {
1052+
void Environment::RemoveCleanupHook(CleanupCallback fn, void* arg) {
10531053
CleanupHookCallback search { fn, arg, 0 };
10541054
cleanup_hooks_.erase(search);
10551055
}

src/env.h

+7-4
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,9 @@ class ShouldNotAbortOnUncaughtScope {
789789

790790
class CleanupHookCallback {
791791
public:
792-
CleanupHookCallback(void (*fn)(void*),
792+
typedef void (*Callback)(void*);
793+
794+
CleanupHookCallback(Callback fn,
793795
void* arg,
794796
uint64_t insertion_order_counter)
795797
: fn_(fn), arg_(arg), insertion_order_counter_(insertion_order_counter) {}
@@ -809,7 +811,7 @@ class CleanupHookCallback {
809811

810812
private:
811813
friend class Environment;
812-
void (*fn_)(void*);
814+
Callback fn_;
813815
void* arg_;
814816

815817
// We keep track of the insertion order for these objects, so that we can
@@ -1171,8 +1173,9 @@ class Environment : public MemoryRetainer {
11711173
void ScheduleTimer(int64_t duration);
11721174
void ToggleTimerRef(bool ref);
11731175

1174-
inline void AddCleanupHook(void (*fn)(void*), void* arg);
1175-
inline void RemoveCleanupHook(void (*fn)(void*), void* arg);
1176+
using CleanupCallback = CleanupHookCallback::Callback;
1177+
inline void AddCleanupHook(CleanupCallback cb, void* arg);
1178+
inline void RemoveCleanupHook(CleanupCallback cb, void* arg);
11761179
void RunCleanup();
11771180

11781181
static void BuildEmbedderGraph(v8::Isolate* isolate,

0 commit comments

Comments
 (0)