Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2017-12-09 07:29:11 +0300
committerAnna Henningsen <anna@addaleax.net>2017-12-13 08:45:57 +0300
commit453008d73ef7248c809d4d1b52c127915b08fc46 (patch)
treeecccf51cbe93e3efbe48a42fde6ccb0fa495d9bf /src/stream_wrap.h
parent24b0f67c2b0b97a4b79f9582e805785cb317daa0 (diff)
src: minor refactoring to StreamBase writes
Instead of having per-request callbacks, always call a callback on the `StreamBase` instance itself for `WriteWrap` and `ShutdownWrap`. This makes `WriteWrap` cleanup consistent for all stream classes, since the after-write callback is always the same now. If special handling is needed for writes that happen to a sub-class, `AfterWrite` can be overridden by that class, rather than that class providing its own callback (e.g. updating the write queue size for libuv streams). If special handling is needed for writes that happen on another stream instance, the existing `after_write_cb()` callback is used for that (e.g. custom code after writing to the transport from a TLS stream). As a nice bonus, this also makes `WriteWrap` and `ShutdownWrap` instances slightly smaller. PR-URL: https://github.com/nodejs/node/pull/17564 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/stream_wrap.h')
-rw-r--r--src/stream_wrap.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/stream_wrap.h b/src/stream_wrap.h
index 91fe642cd97..414bad393fa 100644
--- a/src/stream_wrap.h
+++ b/src/stream_wrap.h
@@ -102,17 +102,18 @@ class LibuvStreamWrap : public HandleWrap, public StreamBase {
static void OnRead(uv_stream_t* handle,
ssize_t nread,
const uv_buf_t* buf);
- static void AfterWrite(uv_write_t* req, int status);
- static void AfterShutdown(uv_shutdown_t* req, int status);
+ static void AfterUvWrite(uv_write_t* req, int status);
+ static void AfterUvShutdown(uv_shutdown_t* req, int status);
// Resource interface implementation
- static void OnAfterWriteImpl(WriteWrap* w, void* ctx);
static void OnAllocImpl(size_t size, uv_buf_t* buf, void* ctx);
static void OnReadImpl(ssize_t nread,
const uv_buf_t* buf,
uv_handle_type pending,
void* ctx);
+ void AfterWrite(WriteWrap* req_wrap, int status) override;
+
uv_stream_t* const stream_;
};