From bd83c3966d4564709e8449b3c699af6ece27ff12 Mon Sep 17 00:00:00 2001 From: Trevor Norris Date: Tue, 9 Dec 2014 05:02:09 +0100 Subject: async-wrap: explicitly pass parent When instantiating a new AsyncWrap allow the parent AsyncWrap to be passed. This is useful for cases like TCP incoming connections, so the connection can be tied to the server receiving the connection. Because the current architecture instantiates the *Wrap inside a v8::FunctionCallback, the parent pointer is currently wrapped inside a new v8::External every time and passed as an argument. This adds ~80ns to instantiation time. A future optimization would be to add the v8::External as the data field when creating the v8::FunctionTemplate, change the pointer just before making the call then NULL'ing it out afterwards. This adds enough code complexity that it will not be attempted until the current approach demonstrates it is a bottle neck. PR-URL: https://github.com/joyent/node/pull/8110 Signed-off-by: Trevor Norris Reviewed-by: Fedor Indutny Reviewed-by: Alexis Campailla Reviewed-by: Julien Gilli --- src/pipe_wrap.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/pipe_wrap.h') diff --git a/src/pipe_wrap.h b/src/pipe_wrap.h index 92492c42b73..959f28f4dca 100644 --- a/src/pipe_wrap.h +++ b/src/pipe_wrap.h @@ -22,6 +22,7 @@ #ifndef SRC_PIPE_WRAP_H_ #define SRC_PIPE_WRAP_H_ +#include "async-wrap.h" #include "env.h" #include "stream_wrap.h" @@ -31,13 +32,16 @@ class PipeWrap : public StreamWrap { public: uv_pipe_t* UVHandle(); - static v8::Local Instantiate(Environment* env); + static v8::Local Instantiate(Environment* env, AsyncWrap* parent); static void Initialize(v8::Handle target, v8::Handle unused, v8::Handle context); private: - PipeWrap(Environment* env, v8::Handle object, bool ipc); + PipeWrap(Environment* env, + v8::Handle object, + bool ipc, + AsyncWrap* parent); static void New(const v8::FunctionCallbackInfo& args); static void Bind(const v8::FunctionCallbackInfo& args); -- cgit v1.2.3