diff options
author | Darshan Sen <darshan.sen@postman.com> | 2021-10-03 07:54:58 +0300 |
---|---|---|
committer | Darshan Sen <darshan.sen@postman.com> | 2021-10-12 08:51:04 +0300 |
commit | a784258444b052dfd31cca90db57b21dc38bb1eb (patch) | |
tree | 0e0aa9a83d9af0a015aed5653bfa6d7e96107d1d /src/stream_pipe.cc | |
parent | 15ce81a4645d5d920187f3b2f832b472d8c47214 (diff) |
src: remove usage of `AllocatedBuffer` from `stream_*`
Signed-off-by: Darshan Sen <darshan.sen@postman.com>
PR-URL: https://github.com/nodejs/node/pull/40293
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'src/stream_pipe.cc')
-rw-r--r-- | src/stream_pipe.cc | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/stream_pipe.cc b/src/stream_pipe.cc index afd7ec36eef..aa636dbb75e 100644 --- a/src/stream_pipe.cc +++ b/src/stream_pipe.cc @@ -1,11 +1,11 @@ #include "stream_pipe.h" -#include "allocated_buffer-inl.h" #include "stream_base-inl.h" #include "node_buffer.h" #include "util-inl.h" namespace node { +using v8::BackingStore; using v8::Context; using v8::Function; using v8::FunctionCallbackInfo; @@ -118,13 +118,13 @@ uv_buf_t StreamPipe::ReadableListener::OnStreamAlloc(size_t suggested_size) { StreamPipe* pipe = ContainerOf(&StreamPipe::readable_listener_, this); size_t size = std::min(suggested_size, pipe->wanted_data_); CHECK_GT(size, 0); - return AllocatedBuffer::AllocateManaged(pipe->env(), size).release(); + return pipe->env()->allocate_managed_buffer(size); } void StreamPipe::ReadableListener::OnStreamRead(ssize_t nread, const uv_buf_t& buf_) { StreamPipe* pipe = ContainerOf(&StreamPipe::readable_listener_, this); - AllocatedBuffer buf(pipe->env(), buf_); + std::unique_ptr<BackingStore> bs = pipe->env()->release_managed_buffer(buf_); if (nread < 0) { // EOF or error; stop reading and pass the error to the previous listener // (which might end up in JS). @@ -144,19 +144,20 @@ void StreamPipe::ReadableListener::OnStreamRead(ssize_t nread, return; } - pipe->ProcessData(nread, std::move(buf)); + pipe->ProcessData(nread, std::move(bs)); } -void StreamPipe::ProcessData(size_t nread, AllocatedBuffer&& buf) { +void StreamPipe::ProcessData(size_t nread, + std::unique_ptr<BackingStore> bs) { CHECK(uses_wants_write_ || pending_writes_ == 0); - uv_buf_t buffer = uv_buf_init(buf.data(), nread); + uv_buf_t buffer = uv_buf_init(static_cast<char*>(bs->Data()), nread); StreamWriteResult res = sink()->Write(&buffer, 1); pending_writes_++; if (!res.async) { writable_listener_.OnStreamAfterWrite(nullptr, res.err); } else { is_reading_ = false; - res.wrap->SetAllocatedStorage(std::move(buf)); + res.wrap->SetBackingStore(std::move(bs)); if (source() != nullptr) source()->ReadStop(); } |