diff options
author | Anatoli Papirovski <apapirovski@mac.com> | 2017-12-11 17:55:17 -0500 |
---|---|---|
committer | Anatoli Papirovski <apapirovski@mac.com> | 2017-12-18 09:58:02 -0500 |
commit | d36e1b4fed57b34d93e70d3408d753e00b8ed754 (patch) | |
tree | 03e0a12b194453231ad7391ff16b2c7cf3a489f2 /src/stream_base.cc | |
parent | 68c63a9fa362138bed852714862ac37b85c06adb (diff) | |
download | android-node-v8-d36e1b4fed57b34d93e70d3408d753e00b8ed754.tar.gz android-node-v8-d36e1b4fed57b34d93e70d3408d753e00b8ed754.tar.bz2 android-node-v8-d36e1b4fed57b34d93e70d3408d753e00b8ed754.zip |
net,src: refactor writeQueueSize tracking
Currently, writeQueueSize is never used in C++ and barely used
within JS. Instead of constantly updating the value on the JS
object, create a getter that will retrieve the most up-to-date
value from C++.
For the vast majority of cases though, create a new prop on
Socket.prototype[kLastWriteQueueSize] using a Symbol. Use this
to track the current write size, entirely in JS land.
PR-URL: https://github.com/nodejs/node/pull/17650
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'src/stream_base.cc')
-rw-r--r-- | src/stream_base.cc | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/stream_base.cc b/src/stream_base.cc index bb25fc1cff..a48e77063e 100644 --- a/src/stream_base.cc +++ b/src/stream_base.cc @@ -193,7 +193,8 @@ int StreamBase::Writev(const FunctionCallbackInfo<Value>& args) { } err = DoWrite(req_wrap, buf_list, count, nullptr); - req_wrap_obj->Set(env->async(), True(env->isolate())); + if (HasWriteQueue()) + req_wrap_obj->Set(env->async(), True(env->isolate())); if (err) req_wrap->Dispose(); @@ -249,7 +250,8 @@ int StreamBase::WriteBuffer(const FunctionCallbackInfo<Value>& args) { req_wrap = WriteWrap::New(env, req_wrap_obj, this); err = DoWrite(req_wrap, bufs, count, nullptr); - req_wrap_obj->Set(env->async(), True(env->isolate())); + if (HasWriteQueue()) + req_wrap_obj->Set(env->async(), True(env->isolate())); req_wrap_obj->Set(env->buffer_string(), args[1]); if (err) @@ -373,7 +375,8 @@ int StreamBase::WriteString(const FunctionCallbackInfo<Value>& args) { reinterpret_cast<uv_stream_t*>(send_handle)); } - req_wrap_obj->Set(env->async(), True(env->isolate())); + if (HasWriteQueue()) + req_wrap_obj->Set(env->async(), True(env->isolate())); if (err) req_wrap->Dispose(); @@ -467,6 +470,10 @@ int StreamResource::DoTryWrite(uv_buf_t** bufs, size_t* count) { return 0; } +bool StreamResource::HasWriteQueue() { + return true; +} + const char* StreamResource::Error() const { return nullptr; |