diff options
author | Trevor Norris <trev.norris@gmail.com> | 2013-09-24 14:12:11 -0700 |
---|---|---|
committer | Trevor Norris <trev.norris@gmail.com> | 2013-10-31 14:17:51 -0700 |
commit | efa62fd9cc817434206d9fd8592b7bbeaa240e9c (patch) | |
tree | d3385ab0c74b20fab8d4e53cfa8408dafec69492 /src/req_wrap.h | |
parent | 21fbbd579080bab569c66100471a4c7b462bb0d6 (diff) | |
download | android-node-v8-efa62fd9cc817434206d9fd8592b7bbeaa240e9c.tar.gz android-node-v8-efa62fd9cc817434206d9fd8592b7bbeaa240e9c.tar.bz2 android-node-v8-efa62fd9cc817434206d9fd8592b7bbeaa240e9c.zip |
node: add AsyncListener support
AsyncListener is a JS API that works in tandem with the AsyncWrap class
to allow the user to be alerted to key events in the life cycle of an
asynchronous event. The AsyncWrap class has its own MakeCallback
implementation that core will be migrated to use, and uses state sharing
techniques to allow quicker communication between JS and C++ whether the
async event callbacks need to be called.
Diffstat (limited to 'src/req_wrap.h')
-rw-r--r-- | src/req_wrap.h | 35 |
1 files changed, 7 insertions, 28 deletions
diff --git a/src/req_wrap.h b/src/req_wrap.h index 8a701e5158..da3abd8759 100644 --- a/src/req_wrap.h +++ b/src/req_wrap.h @@ -22,6 +22,8 @@ #ifndef SRC_REQ_WRAP_H_ #define SRC_REQ_WRAP_H_ +#include "async-wrap.h" +#include "async-wrap-inl.h" #include "env.h" #include "env-inl.h" #include "queue.h" @@ -33,21 +35,14 @@ namespace node { extern QUEUE req_wrap_queue; template <typename T> -class ReqWrap { +class ReqWrap : public AsyncWrap { public: - ReqWrap(Environment* env, - v8::Handle<v8::Object> object = v8::Handle<v8::Object>()) - : env_(env) { - v8::HandleScope handle_scope(env->isolate()); + ReqWrap(Environment* env, v8::Handle<v8::Object> object) + : AsyncWrap(env, object) { + assert(!object.IsEmpty()); - if (object.IsEmpty()) { - object = v8::Object::New(); - } - persistent().Reset(env->isolate(), object); - - if (env->in_domain()) { + if (env->in_domain()) object->Set(env->domain_string(), env->domain_array()->Get(0)); - } QUEUE_INSERT_TAIL(&req_wrap_queue, &req_wrap_queue_); } @@ -66,25 +61,9 @@ class ReqWrap { req_.data = this; } - inline Environment* env() const { - return env_; - } - - inline v8::Local<v8::Object> object() { - return PersistentToLocal(env()->isolate(), persistent()); - } - - inline v8::Persistent<v8::Object>& persistent() { - return object_; - } - // TODO(bnoordhuis) Make these private. QUEUE req_wrap_queue_; T req_; // *must* be last, GetActiveRequests() in node.cc depends on it - - private: - v8::Persistent<v8::Object> object_; - Environment* const env_; }; |