Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: remove asyncwrapobject #35511

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 0 additions & 46 deletions src/async_wrap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ using v8::PropertyAttribute;
using v8::PropertyCallbackInfo;
using v8::ReadOnly;
using v8::String;
using v8::Uint32;
using v8::Undefined;
using v8::Value;
using v8::WeakCallbackInfo;
Expand All @@ -71,45 +70,6 @@ static const char* const provider_names[] = {
#undef V
};


struct AsyncWrapObject : public AsyncWrap {
static inline void New(const FunctionCallbackInfo<Value>& args) {
Environment* env = Environment::GetCurrent(args);
CHECK(args.IsConstructCall());
CHECK(env->async_wrap_object_ctor_template()->HasInstance(args.This()));
CHECK(args[0]->IsUint32());
auto type = static_cast<ProviderType>(args[0].As<Uint32>()->Value());
new AsyncWrapObject(env, args.This(), type);
}

inline AsyncWrapObject(Environment* env, Local<Object> object,
ProviderType type) : AsyncWrap(env, object, type) {}

static Local<FunctionTemplate> GetConstructorTemplate(Environment* env) {
Local<FunctionTemplate> tmpl = env->async_wrap_object_ctor_template();
if (tmpl.IsEmpty()) {
tmpl = env->NewFunctionTemplate(AsyncWrapObject::New);
tmpl->SetClassName(
FIXED_ONE_BYTE_STRING(env->isolate(), "AsyncWrap"));
tmpl->Inherit(AsyncWrap::GetConstructorTemplate(env));
tmpl->InstanceTemplate()->SetInternalFieldCount(
AsyncWrapObject::kInternalFieldCount);
env->set_async_wrap_object_ctor_template(tmpl);
}
return tmpl;
}

bool IsNotIndicativeOfMemoryLeakAtExit() const override {
// We can't really know what the underlying operation does. One of the
// signs that it's time to remove this class. :)
return true;
}

SET_NO_MEMORY_INFO()
SET_MEMORY_INFO_NAME(AsyncWrapObject)
SET_SELF_SIZE(AsyncWrapObject)
};

void AsyncWrap::DestroyAsyncIdsCallback(Environment* env) {
Local<Function> fn = env->async_hooks_destroy_function();

Expand Down Expand Up @@ -751,11 +711,6 @@ void AsyncWrap::Initialize(Local<Object> target,
env->set_async_hooks_promise_resolve_function(Local<Function>());
env->set_async_hooks_binding(target);

target->Set(env->context(),
FIXED_ONE_BYTE_STRING(env->isolate(), "AsyncWrap"),
AsyncWrapObject::GetConstructorTemplate(env)
->GetFunction(env->context()).ToLocalChecked()).Check();

// TODO(qard): maybe this should be GetConstructorTemplate instead?
PromiseWrap::Initialize(env);
}
Expand All @@ -772,7 +727,6 @@ void AsyncWrap::RegisterExternalReferences(
registry->Register(EnablePromiseHook);
registry->Register(DisablePromiseHook);
registry->Register(RegisterDestroyHook);
registry->Register(AsyncWrapObject::New);
registry->Register(AsyncWrap::GetAsyncId);
registry->Register(AsyncWrap::AsyncReset);
registry->Register(AsyncWrap::GetProviderType);
Expand Down