| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -91,7 +91,7 @@ StreamWriteResult StreamBase::Write(uv_buf_t* bufs, | |||
| 91 | 91 | for (size_t i = 0; i < count; ++i) total_bytes += bufs[i].len; | |
| 92 | 92 | bytes_written_ += total_bytes; | |
| 93 | 93 | ||
| 94 | - if (send_handle == nullptr && !skip_try_write) { | ||
| 94 | + if (send_handle == nullptr && HasDoTryWrite() && !skip_try_write) { | ||
| 95 | 95 | err = DoTryWrite(&bufs, &count); | |
| 96 | 96 | if (err != 0 || count == 0) { | |
| 97 | 97 | return StreamWriteResult{false, err, nullptr, total_bytes, {}}; | |
@@ -365,7 +365,7 @@ int StreamBase::WriteString(const FunctionCallbackInfo<Value>& args) { | |||
| 365 | 365 | size_t synchronously_written = 0; | |
| 366 | 366 | uv_buf_t buf; | |
| 367 | 367 | ||
| 368 | - bool try_write = storage_size <= sizeof(stack_storage) && | ||
| 368 | + bool try_write = HasDoTryWrite() && storage_size <= sizeof(stack_storage) && | ||
| 369 | 369 | (!IsIPCPipe() || send_handle_obj.IsEmpty()); | |
| 370 | 370 | if (try_write) { | |
| 371 | 371 | data_size = StringBytes::Write(isolate, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -244,6 +244,8 @@ class StreamResource { | |||
| 244 | 244 | // `*bufs` and `*count` accordingly. This is a no-op by default. | |
| 245 | 245 | // Return 0 for success and a libuv error code for failures. | |
| 246 | 246 | virtual int DoTryWrite(uv_buf_t** bufs, size_t* count); | |
| 247 | + // Indicates whether this subclass overrides the DoTryWrite | ||
| 248 | + virtual inline bool HasDoTryWrite() const { return false; } | ||
| 247 | 249 | // Initiate a write of data. | |
| 248 | 250 | // Upon an immediate failure, a libuv error code is returned, | |
| 249 | 251 | // w->Done() will never be called and caller should free `bufs`. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -52,6 +52,7 @@ class LibuvStreamWrap : public HandleWrap, public StreamBase { | |||
| 52 | 52 | // Resource implementation | |
| 53 | 53 | int DoShutdown(ShutdownWrap* req_wrap) override; | |
| 54 | 54 | int DoTryWrite(uv_buf_t** bufs, size_t* count) override; | |
| 55 | + inline bool HasDoTryWrite() const override { return true; } | ||
| 55 | 56 | int DoWrite(WriteWrap* w, | |
| 56 | 57 | uv_buf_t* bufs, | |
| 57 | 58 | size_t count, | |
| Back | FazBrowse Home | New Git URL |
0 commit comments