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: make StreamBase::GetAsyncWrap pure virtual #13174

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
24 changes: 5 additions & 19 deletions src/stream_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ int StreamBase::Shutdown(const FunctionCallbackInfo<Value>& args) {
Local<Object> req_wrap_obj = args[0].As<Object>();

AsyncWrap* wrap = GetAsyncWrap();
if (wrap != nullptr)
env->set_init_trigger_id(wrap->get_id());
CHECK_NE(wrap, nullptr);
env->set_init_trigger_id(wrap->get_id());
ShutdownWrap* req_wrap = new ShutdownWrap(env,
req_wrap_obj,
this,
Expand Down Expand Up @@ -133,8 +133,6 @@ int StreamBase::Writev(const FunctionCallbackInfo<Value>& args) {
return UV_ENOBUFS;

AsyncWrap* wrap = GetAsyncWrap();
// NOTE: All tests show that GetAsyncWrap() never returns nullptr here. If it
// can then replace the CHECK_NE() with if (wrap != nullptr).
CHECK_NE(wrap, nullptr);
env->set_init_trigger_id(wrap->get_id());
WriteWrap* req_wrap = WriteWrap::New(env,
Expand Down Expand Up @@ -425,16 +423,9 @@ void StreamBase::EmitData(ssize_t nread,
if (argv[2].IsEmpty())
argv[2] = Undefined(env->isolate());

AsyncWrap* async = GetAsyncWrap();
if (async == nullptr) {
node::MakeCallback(env,
GetObject(),
env->onread_string(),
arraysize(argv),
argv);
} else {
async->MakeCallback(env->onread_string(), arraysize(argv), argv);
}
AsyncWrap* wrap = GetAsyncWrap();
CHECK_NE(wrap, nullptr);
wrap->MakeCallback(env->onread_string(), arraysize(argv), argv);
}


Expand All @@ -448,11 +439,6 @@ int StreamBase::GetFD() {
}


AsyncWrap* StreamBase::GetAsyncWrap() {
return nullptr;
}


Local<Object> StreamBase::GetObject() {
return GetAsyncWrap()->object();
}
Expand Down
2 changes: 1 addition & 1 deletion src/stream_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ class StreamBase : public StreamResource {
virtual ~StreamBase() = default;

// One of these must be implemented
virtual AsyncWrap* GetAsyncWrap();
virtual AsyncWrap* GetAsyncWrap() = 0;
virtual v8::Local<v8::Object> GetObject();

// Libuv callbacks
Expand Down