Skip to content

Commit

Permalink
src: remove dead code in async_wrap
Browse files Browse the repository at this point in the history
The silent option for AsyncWrap and AsyncReset is not used anywhere.

Seems like a leftover from times PromiseWrap was used.

PR-URL: nodejs#56065
Refs: nodejs#39135
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
  • Loading branch information
Flarna authored and nodejs-github-bot committed Dec 4, 2024
1 parent 5eb639b commit d537061
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 35 deletions.
23 changes: 2 additions & 21 deletions src/async_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -488,31 +488,15 @@ AsyncWrap::AsyncWrap(Environment* env,
Local<Object> object,
ProviderType provider,
double execution_async_id)
: AsyncWrap(env, object, provider, execution_async_id, false) {}

AsyncWrap::AsyncWrap(Environment* env,
Local<Object> object,
ProviderType provider,
double execution_async_id,
bool silent)
: AsyncWrap(env, object) {
CHECK_NE(provider, PROVIDER_NONE);
provider_type_ = provider;

// Use AsyncReset() call to execute the init() callbacks.
AsyncReset(object, execution_async_id, silent);
AsyncReset(object, execution_async_id);
init_hook_ran_ = true;
}

AsyncWrap::AsyncWrap(Environment* env,
Local<Object> object,
ProviderType provider,
double execution_async_id,
double trigger_async_id)
: AsyncWrap(env, object, provider, execution_async_id, true) {
trigger_async_id_ = trigger_async_id;
}

AsyncWrap::AsyncWrap(Environment* env, Local<Object> object)
: BaseObject(env, object),
context_frame_(env->isolate(),
Expand Down Expand Up @@ -592,8 +576,7 @@ void AsyncWrap::EmitDestroy(Environment* env, double async_id) {
// Generalized call for both the constructor and for handles that are pooled
// and reused over their lifetime. This way a new uid can be assigned when
// the resource is pulled out of the pool and put back into use.
void AsyncWrap::AsyncReset(Local<Object> resource, double execution_async_id,
bool silent) {
void AsyncWrap::AsyncReset(Local<Object> resource, double execution_async_id) {
CHECK_NE(provider_type(), PROVIDER_NONE);

if (async_id_ != kInvalidAsyncId) {
Expand Down Expand Up @@ -642,8 +625,6 @@ void AsyncWrap::AsyncReset(Local<Object> resource, double execution_async_id,

context_frame_.Reset(isolate, async_context_frame::current(isolate));

if (silent) return;

EmitAsyncInit(env(), resource,
env()->async_hooks()->provider_string(provider_type()),
async_id_, trigger_async_id_);
Expand Down
15 changes: 1 addition & 14 deletions src/async_wrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,7 @@ class AsyncWrap : public BaseObject {
inline v8::Local<v8::Value> context_frame() const;

void AsyncReset(v8::Local<v8::Object> resource,
double execution_async_id = kInvalidAsyncId,
bool silent = false);
double execution_async_id = kInvalidAsyncId);

// Only call these within a valid HandleScope.
v8::MaybeLocal<v8::Value> MakeCallback(const v8::Local<v8::Function> cb,
Expand Down Expand Up @@ -224,18 +223,6 @@ class AsyncWrap : public BaseObject {
bool IsDoneInitializing() const override;

private:
friend class PromiseWrap;

AsyncWrap(Environment* env,
v8::Local<v8::Object> promise,
ProviderType provider,
double execution_async_id,
bool silent);
AsyncWrap(Environment* env,
v8::Local<v8::Object> promise,
ProviderType provider,
double execution_async_id,
double trigger_async_id);
ProviderType provider_type_ = PROVIDER_NONE;
bool init_hook_ran_ = false;
// Because the values may be Reset(), cannot be made const.
Expand Down

0 comments on commit d537061

Please sign in to comment.