diff options
author | Anna Henningsen <anna@addaleax.net> | 2018-02-08 04:59:10 +0100 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2018-02-14 10:00:29 +0100 |
commit | 0e7b61229aa602e55c5fb034a63d7da97eecff3b (patch) | |
tree | 0e64305591fd94e1b609c5fd4ba1ae1bd19ea66a /src/js_stream.cc | |
parent | 0ed9ea861b847579478457b7f5aab430fb6d77cb (diff) | |
download | node-new-0e7b61229aa602e55c5fb034a63d7da97eecff3b.tar.gz |
src: refactor WriteWrap and ShutdownWraps
Encapsulate stream requests more:
- `WriteWrap` and `ShutdownWrap` classes are now tailored to the
streams on which they are used. In particular, for most streams
these are now plain `AsyncWrap`s and do not carry the overhead
of unused libuv request data.
- Provide generic `Write()` and `Shutdown()` methods that wrap
around the actual implementations, and make *usage* of streams
easier, rather than implementing; for example, wrap objects
don’t need to be provided by callers anymore.
- Use `EmitAfterWrite()` and `EmitAfterShutdown()` handlers to
call the corresponding JS handlers, rather than always trying
to call them. This makes usage of streams by other C++ code
easier and leaner.
Also fix up some tests that were previously not actually testing
asynchronicity when the comments indicated that they would.
PR-URL: https://github.com/nodejs/node/pull/18676
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/js_stream.cc')
-rw-r--r-- | src/js_stream.cc | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/src/js_stream.cc b/src/js_stream.cc index 9e67a2094d..3ba6a254cf 100644 --- a/src/js_stream.cc +++ b/src/js_stream.cc @@ -91,8 +91,6 @@ int JSStream::DoShutdown(ShutdownWrap* req_wrap) { req_wrap->object() }; - req_wrap->Dispatched(); - TryCatch try_catch(env()->isolate()); Local<Value> value; int value_int = UV_EPROTO; @@ -127,8 +125,6 @@ int JSStream::DoWrite(WriteWrap* w, bufs_arr }; - w->Dispatched(); - TryCatch try_catch(env()->isolate()); Local<Value> value; int value_int = UV_EPROTO; @@ -154,9 +150,8 @@ void JSStream::New(const FunctionCallbackInfo<Value>& args) { template <class Wrap> void JSStream::Finish(const FunctionCallbackInfo<Value>& args) { - Wrap* w; CHECK(args[0]->IsObject()); - ASSIGN_OR_RETURN_UNWRAP(&w, args[0].As<Object>()); + Wrap* w = static_cast<Wrap*>(StreamReq::FromObject(args[0].As<Object>())); w->Done(args[1]->Int32Value()); } |